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

Does not work with babel-plugin-lodash #558

Open
simonihmig opened this issue Jan 5, 2023 · 0 comments
Open

Does not work with babel-plugin-lodash #558

simonihmig opened this issue Jan 5, 2023 · 0 comments

Comments

@simonihmig
Copy link
Contributor

I was trying to use babel-plugin-lodash to get rid off the monolithic lodash.js module and instead get cherry-picked and tree-shaken individual lodash/* modules everywhere. While the babel plugin works, and indeed rewrites all the imports, I still end up having both the monolithic lodash.js as well as the individual modules:

image

I searched through the /dist output to see what is pulling this in, but there is nothing anymore depending on it. There is a d('lodash', ...) AMD shim in chunk.app.*.js, but no other define() that actually consumes this. Also putting a breakpoint in front of the actual module (the webpack emitted eval()) confirms that it is unused.

When looking at the output of BROCCOLI_DEBUG=ember-auto-import:preprocessor:* ember b, I see modules like these (some irrelevant ... parts omitted):

define("some-module, ["exports", "lodash/cloneDeep", "faker", ...], function (_exports, _cloneDeep2, _faker, ...) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  0; //eaimeta@70e063a35619d71f0,"lodash/cloneDeep",0,"lodash",0,"faker", ...

The original source has a import _ from 'lodash'; and somewhere else some _.cloneDeep() calls. So the babel plugin does its job obviously, but looking at that eaimeta... embedded serialization it seems eai still thinks that lodash is imported. First I thought it might be related to the execution order of babel plugins, but what puzzles me is that in that eaimeta... both lodash/cloneDeep (which must come from babel-plugin-lodash) as well as lodash are present.

Also confusing to me is the fact that the tree passed to the Analyzer (by looking at the output of BROCCOLI_DEBUG=ember-auto-import:preprocessor:*) already contains those eaimeta..., as this is the input of the Analyzer here. But maybe I am misunderstanding something...

/cc @NullVoxPopuli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant