Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

babel lodash plugin and parcel tree shaking #1821

Closed
zxol opened this issue Jul 30, 2018 · 0 comments · Fixed by #2292
Closed

babel lodash plugin and parcel tree shaking #1821

zxol opened this issue Jul 30, 2018 · 0 comments · Fixed by #2292
Labels

Comments

@zxol
Copy link

zxol commented Jul 30, 2018

🐛 bug report

lodash plugin for babel does not seem to work with parcel --experimental-scope-hoisting

🎛 Configuration (.babelrc, package.json, cli command)

{
    "name": "parcelbabel",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "build": "NODE_ENV=production && rm -rf ./dist && parcel build --experimental-scope-hoisting index.html"

    },
    "author": "",
    "license": "ISC",
    "devDependencies": {
        "babel-plugin-lodash": "^3.3.4",
        "parcel-bundler": "^1.9.7"
    },
    "babel": {
        "plugins": ["lodash"]
    }
}

🤔 Expected Behavior

It should build properly.

😯 Current Behavior

Build errors out with the following error:

🚨  /home/andymac/devl/parcelbabel/index.js: Cannot read property 'constantViolations' of undefined
    at rename (/home/andymac/devl/parcelbabel/node_modules/parcel-bundler/src/scope-hoisting/renamer.js:9:33)
    at JSAsset.ImportDeclaration (/home/andymac/devl/parcelbabel/node_modules/parcel-bundler/src/scope-hoisting/hoist.js:327:7)
    at NodePath._call (/home/andymac/devl/parcelbabel/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/home/andymac/devl/parcelbabel/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/home/andymac/devl/parcelbabel/node_modules/babel-traverse/lib/path/context.js:105:12)
    at TraversalContext.visitQueue (/home/andymac/devl/parcelbabel/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitMultiple (/home/andymac/devl/parcelbabel/node_modules/babel-traverse/lib/context.js:103:17)
    at TraversalContext.visit (/home/andymac/devl/parcelbabel/node_modules/babel-traverse/lib/context.js:190:19)
    at Function.traverse.node (/home/andymac/devl/parcelbabel/node_modules/babel-traverse/lib/index.js:114:17)
    at NodePath.visit (/home/andymac/devl/parcelbabel/node_modules/babel-traverse/lib/path/context.js:115:19)

💁 Possible Solution

Not sure. I know I could (and I have) refactored my code to use 'lodash-es' and import single functions. But I thought this bug report could be useful.

🔦 Context

💻 Code Sample

minimal code sample:
https://github.com/zxol/parcelbabel

🌍 Your Environment

Software Version(s)
Parcel 1.97
Node 8.11.3
npm/Yarn 5.5.1
Operating System ubuntu 16.04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants