You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried pulling in this npm package and compiling it with webpack but I get the following errors:
ERROR in ./node_modules/micropython/index.js
Module not found: Error: Can't resolve 'fs' in './micropython_example/node_modules/micropython'
@ ./node_modules/micropython/index.js 21:9-22
@ ./assets/js/app.js
@ ./assets/js/index.js
ERROR in ./node_modules/micropython/lib/micropython.js
Module not found: Error: Can't resolve 'fs' in './micropython_example/node_modules/micropython/lib'
@ ./node_modules/micropython/lib/micropython.js 39:15-28 80:13-26 179:28-41 3005:23-36
@ ./node_modules/micropython/index.js
@ ./assets/js/app.js
@ ./assets/js/index.js
This appears to be because webpack is not detecting that it can never go down the "node-only" path and still trying to require fs. If I add typeof __webpack_require__ !== 'function' on every branch that requires fs, everything works. But I don't know enough about webpack to be confident such changes are a good idea and/or they wouldn't break it for someone else.
Reading through various issues (including webpack/webpack#7352), looks like you can get around issues in the emscripten generated javascript (lib/micropython.js) by adding an ignore plugin to the webpack config:
plugins: [
...
newwebpack.IgnorePlugin(/^fs$/),],
This does not fix the issue in index.js. I'm pretty sure this code:
does not work as intended. When running in the brower, webpackJsonp is undefined even when it was originally built with webpack. Perhaps using typeof window === 'undefined' would be better?
I tried pulling in this npm package and compiling it with webpack but I get the following errors:
This appears to be because webpack is not detecting that it can never go down the "node-only" path and still trying to require
fs
. If I addtypeof __webpack_require__ !== 'function'
on every branch that requiresfs
, everything works. But I don't know enough about webpack to be confident such changes are a good idea and/or they wouldn't break it for someone else.You can see my webpack version and config and a working example at https://github.com/tessereth/micropython_wasm_example.
The text was updated successfully, but these errors were encountered: