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
WMR prefers to load "node" over "default" in the package.json#exports.
Here is a minimal repro:
yarn create wmr your-project-name
cd your-project-name
mkdir node_modules/test
echo'{"name":"test", "exports":{".":{"node":"./node.mjs", "default":"./browser.mjs"}}}'> node_modules/test/package.json
echo'export default "Browser implementation"'> node_modules/test/browser.mjs
echo'import "node:url";export default "Node.js implementation"'> node_modules/test/node.mjs
echo'import test from "test";export default function Home(){return <div>{test}</div>}'> public/pages/home/index.js
yarn build
This outputs a warning ('node:url' is imported bynpm/test/node.mjs, but could not be resolved – treating it as an external dependency) and builds the home page using <div>Node.js implementation</div> instead of the expected <div>Browser implementation</div>.
WMR prefers to load
"node"
over"default"
in thepackage.json#exports
.Here is a minimal repro:
This outputs a warning (
'node:url' is imported bynpm/test/node.mjs, but could not be resolved – treating it as an external dependency
) and builds the home page using<div>Node.js implementation</div>
instead of the expected<div>Browser implementation</div>
.Expected
Actual
Additional info
BTW, if the
test
module is not using thenode:
prefix to load the Node.js module, the builds will just fails:For reference,
@rollup/plugin-node-resolve
and Webpack both prefers"default"
over"node"
in the same situation.The text was updated successfully, but these errors were encountered: