jupyterlite / jupyterlite/pyodide-kernel
Newer `terser` breaks the production build
- Dominant language
- Python
- Stars
- 90
- Forks
- 47
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 11
Description
After updating dependencies in https://github.com/jupyterlite/pyodide-kernel/pull/226, starting a new kernel using a production of `jupyterlite-pyodide-kernel` fails with:
```
Failed to construct 'Worker': Failed to read the 'type' property from 'WorkerOptions':
Cannot convert object to primitive value
```
In `packages/pyodide-kernel/src/kernel.ts`, workers are created with:
```javascript
new Worker(new URL('./comlink.worker.js', import.meta.url), {
type: 'module',
})
```
Looking more closely at the built assets:
**Dev:**
```javascript
new Worker(new URL(...), {
type: undefined,
})
```
**Prod (minified):**
```javascript
new Worker(new URL(...), {
type: s, // Variable reused - 's' is the pypi import namespace object
})
```
This seems to be caused by a new version of `terser`, which likely introduced more aggressive variable reuse optimizations.
The UI tests didn't catch this because they were using the dev build, where the issue doesn't manifest.
Contributor guide
Assessment
This issue has not been assessed yet.