browser field of package.json not resolved
AndyOGo opened this issue · 7 comments
We used to include nanomorph
which uses node's assert built-in for the server but replaces it by nanoassert
for the browser.
Since we upgraded to version 3.3.0
we get following errors:
'assert' is imported by node_modules/nanomorph/index.js, but could not be resolved – treating it as an external dependency
‘assert’ is imported by commonjs-external:assert, but could not be resolved – treating it as an external dependency
Creating a browser bundle that depends on Node.js built-in module (‘assert’). You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins
Our rollup-config for this plugin includes the browser: true
option as described in your usage.
Solution: we stay at version 3.0.0
!
i'm encounter with the same problem
Fixed by update version. Also, the bug was related to another package. They fix the issue. Can be closed now.
@mecurc Thanks.
May I ask you to give us some more details about this other package? Name, version, etc.
it's here: https://github.com/choojs/nanomorph/pull/108/files
They just import assert instead of nanoassert.
@mecurc
Thanks, I see.
Though as I understood, it's perfectly fine to rename modules by browser
field, like they did it:
https://github.com/choojs/nanomorph/blob/43d39d01a9c14a8279e398bad93c1ef6edfa03a4/package.json#L27-L29
The browser
field spec here:
https://github.com/defunctzombie/package-browser-field-spec
@mecurc I have a same similar issue with import of https://github.com/kelektiv/node-uuid. The browser override is not used in case of import with import uuid from 'uuid/v4';
The https://www.npmjs.com/package/@types/uuid is used. A sample project that produces output with a wrong file included https://github.com/melgenek/uuid-typescript-rollup