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
{{ message }}
This repository has been archived by the owner on May 17, 2019. It is now read-only.
Browser builds with node polyfills does not work with .mjs files
Type of issue
Bug
Description
If a browser file has an .mjs extension and uses a node builtin (e.g. process), and the project has the process polyfill configured, the compiled code will reference require rather than __webpack_require__. This causes an uncaught exception in the browser since require is not defined.
NOTE: There are likely many other issues with .mjs files. We should take verify that other aspects of the build process work with .mjs files.
Current behavior
Generates code using require:
/* WEBPACK VAR INJECTION */}.call(this,require("./../../node_modules/node-libs-browser/mock/process.js")))
Expected behavior
Should generate code using webpack_require:
/* WEBPACK VAR INJECTION */}.call(this,__webpack_require__(/*! ./../node_modules/node-libs-browser/mock/process.js */"./node_modules/node-libs-browser/mock/process.js")))
Steps to reproduce
Scaffold a fusion project
Update the package.json to have:
{
"node": {
"process": true,
"Buffer": true
}
}
Add a file: test.mjs with the following contents
exportdefaultfunctiontest(){console.log(process)}
import and use the test function in src/main.js
importtestfrom'./test.mjs';test();
run fusion dev
The text was updated successfully, but these errors were encountered:
Browser builds with node polyfills does not work with .mjs files
Type of issue
Bug
Description
If a browser file has an
.mjs
extension and uses a node builtin (e.g. process), and the project has the process polyfill configured, the compiled code will referencerequire
rather than__webpack_require__
. This causes an uncaught exception in the browser sincerequire
is not defined.NOTE: There are likely many other issues with
.mjs
files. We should take verify that other aspects of the build process work with.mjs
files.Current behavior
Generates code using require:
Expected behavior
Should generate code using webpack_require:
Steps to reproduce
test.mjs
with the following contentssrc/main.js
fusion dev
The text was updated successfully, but these errors were encountered: