Skip to content

Commit

Permalink
Remove known issues with esm
Browse files Browse the repository at this point in the history
esm builds are working now without issue. Full support for both
commonjs and esm builds is added.

Addresses #21. We no longer allow webpack to try and parse the
emscripten build. We do that ourselves.
  • Loading branch information
mneil committed Nov 16, 2023
1 parent da2c3b9 commit e52934a
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,47 +81,6 @@ Default: `https://cdn.jsdelivr.net/pyodide/v${installedPyodideVersion}/full/`\
Required: false\
_Description_: CDN endpoint for python packages. This option differs from [loadPyodide indexUrl](https://pyodide.org/en/stable/usage/api/js-api.html) in that it only impacts pip packages and _does not_ affect the location the main pyodide runtime location. Set this value to "" if you want to keep the pyodide default of accepting the indexUrl.

## Known issues with esm

> ESM builds are currently failing if you use the pyodide esm module. You can fix this by importing the commonjs build into your project `import { loadPyodide } from "pyodide/pyodide.js";`
Depending on your webpack configuration you may run into issues with webpack trying to parse your pyodide.mjs file.

**Can't resolve 'url' in ...**

[Issue #8](https://github.com/pyodide/pyodide-webpack-plugin/issues/8) deals with this error and pyodide esm. To fix this issue:

- `npm i -D url`
- Add a [fall back](https://webpack.js.org/configuration/resolve/#resolvefallback) to your webpack config
```js
resolve: {
fallback: {
url: require.resolve("url/"),
},
},
```

**Cannot find module '<...>/pyodide.asm.js.**
This can happen when webpack munges esm import statements to \_\_webpack_require\_\_ when you actually intend import to work in the browser.
- `npm i -D string-replace-loader`
- Add a [rule](https://webpack.js.org/configuration/module/#rule) to your webpack config
```js
{
test: /pyodide\.m?js$/,
use: [
{
loader: 'string-replace-loader',
options: {
search: 'import(',
replace: 'import(/* webpackIgnore: true */ '
}
}
]
}
```
## Contributing

Please view the [contributing guide](./CONTRIBUTING.md) for tips on filing issues, making changes, and submitting pull requests. Pyodide is an independent and community-driven open-source project. The decision-making process is outlined in the [Project governance](https://pyodide.org/en/stable/project/governance.html).
Expand Down

0 comments on commit e52934a

Please sign in to comment.