When importing this package using named exports https://www.npmjs.com/package/@material-ui/icons
it freezes ParcelJS.
Default, using jsx
Parcel should build as always
It freezes and consumes all CPU and Memory
Could it be possible to parse only the files that are being imported by analyzing indexes (index.js)?
Trying to import using named exports from a big big package
import { AccessAlarm, ThreeDRotation } from '@material-ui/icons';
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.9.6
| Node | 8.10.0
| npm/Yarn | 1.9.2
| Operating System | Ubuntu 18.04.1 LTS
It's probably better if you use something like this: import AccessAlarm from '@material-ui/icons/AccessAlarm'; in the meantime, so it does not crash.
But I totally agree it would be amazing if parcel would be smarter in handling imports and allow adding of metadata to dependencies (Possible in Parcel 2). Sort of an explicit pre-optimisation treeshaking.
let dep = {
loc: {
filePath: '/Users/.../project/node_modules/@material-ui/icons/index.js'
},
moduleSpecifier: '@material-ui/icons',
meta: {
requiredKeys: ['AccessAlarm', 'ThreeDRotation'] // Importing everything would be `*` or a non existing `requiredKeys` in metadata
}
}
For the (current) dependency typing for Parcel 2 see https://github.com/parcel-bundler/parcel/blob/next/types.js#L37 (This might and will probably change)
Same issue here. It bundles @material-ui/core fine, with or without --experimental-scope-hoisting. But it freezes up when using named imports on @material-ui/icons. I tried both with and without the flag. Same OS, Parcel 1.9.7.
I also found that babel-plugin-import seems to do the trick. It converts named imports as if they were direct imports. It doesn't play nicely with --experimental-scope-hoisting however, as I get Cannot read property 'constantViolations' of undefined.
Is there anything else that can be done for now to allow for named imports? Any config overwrite? Thanks
@DeMoorJasper then we don't have Configuration less bundler :(
I think this would be really different than what is Parcel intended for and will not be as easy implementable.
@Stradivario not sure what you mean? The dependency object is just how parcel internally passes and manipulates dependencies
Sent with GitHawk
@DeMoorJasper
Sorry about my lack of information about parcel then ;)
Related: #1567
Implemented in #2967
Fixed in Parcel 2
Most helpful comment
It's probably better if you use something like this:
import AccessAlarm from '@material-ui/icons/AccessAlarm';in the meantime, so it does not crash.But I totally agree it would be amazing if parcel would be smarter in handling imports and allow adding of metadata to dependencies (Possible in Parcel 2). Sort of an explicit pre-optimisation treeshaking.
For the (current) dependency typing for Parcel 2 see https://github.com/parcel-bundler/parcel/blob/next/types.js#L37 (This might and will probably change)