Parcel: Bad performance with big packages

Created on 31 Aug 2018  ยท  8Comments  ยท  Source: parcel-bundler/parcel

๐Ÿ› bug report

When importing this package using named exports https://www.npmjs.com/package/@material-ui/icons
it freezes ParcelJS.

๐ŸŽ› Configuration (.babelrc, package.json, cli command)

Default, using jsx

๐Ÿค” Expected Behavior

Parcel should build as always

๐Ÿ˜ฏ Current Behavior

It freezes and consumes all CPU and Memory

๐Ÿ’ Possible Solution

Could it be possible to parse only the files that are being imported by analyzing indexes (index.js)?

๐Ÿ”ฆ Context

Trying to import using named exports from a big big package

๐Ÿ’ป Code Sample

import { AccessAlarm, ThreeDRotation } from '@material-ui/icons';

๐ŸŒ Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.9.6
| Node | 8.10.0
| npm/Yarn | 1.9.2
| Operating System | Ubuntu 18.04.1 LTS

Bug Confirmed Bug โœจ 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.

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)

All 8 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

algebraic-brain picture algebraic-brain  ยท  3Comments

philipodev picture philipodev  ยท  3Comments

davidnagli picture davidnagli  ยท  3Comments

donaldallen picture donaldallen  ยท  3Comments

oliger picture oliger  ยท  3Comments