Closed erictooth closed 3 years ago
The same thing causes any app that depends on react-mosaic
to fail building with parcel2:
$ parcel build src/index.js
🚨 Build failed.
@parcel/packager-js: `require.resolve` calls for excluded assets are only supported with outputFormat: 'commonjs'
/home/user/project/node_modules/react-mosaic-component/lib/util/OptionalBlueprint.js:32:9
31 | // https://github.com/nomcopter/react-mosaic/issues/109
> 32 | require.resolve('@blueprintjs/core');
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33 | require.resolve('@blueprintjs/icons');
34 | (_a = require('@blueprintjs/core'), Classes = _a.Classes, OptionalBlueprint.Icon = _a.Icon);
The babel-plugin-transform-remove-imports
workaround does not work with Parcel either, since it does not apply transforms to third-party packages :-/
Fixed in 602b0d5447d8ffd23a0cbf3fca917c5736735ecd
Bug report
Steps to reproduce
Actual behavior
When loading the app, Chrome shows the error:
When building the app, Snowpack shows the warning (expected):
Expected behavior
Using react-mosaic in an app distributed via native modules should not cause an error to be thrown due to an optional dependency.
For now I've added babel-plugin-transform-remove-imports to my project to remove
import
lines for blueprintjs. Any idea if there’s a better solution?