jupyterlite / jupyterlite/pyodide-kernel

Newer `terser` breaks the production build

Open
#232 3 comments 0 reactions 0 assignees View on GitHub
maintenance
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
})
```

Image

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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.