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

Conditional import #16

Open
samselikoff opened this issue Jan 25, 2016 · 6 comments
Open

Conditional import #16

samselikoff opened this issue Jan 25, 2016 · 6 comments

Comments

@samselikoff
Copy link
Contributor

I'm trying to figure out if it's possible to use this library in my addon, but optionally not import lodash into the host app's final vendor.js. I use this in Ember CLI Mirage, which is primarily enabled in development/testing.

Is there a strategy I can take for a Mirage option be used at build-time to exclude lodash? I'm happy to PR once I have a better idea. My broccoli-fu is weak.

@tchak
Copy link
Collaborator

tchak commented Mar 9, 2016

I fully agree this is a huge problem. I suspect this is something faced by other addons.

I would like to try to solve it by looking in to babel-plugin-lodash. If I can find a way to include in builds only imported modules it would be a huge win.

@tchak
Copy link
Collaborator

tchak commented Mar 9, 2016

I am just realising that using babel-plugin-lodash is not even remotely an option before ember-cli is updated to use babel 6...

@tchak
Copy link
Collaborator

tchak commented Mar 9, 2016

I am so 😭 😭 😭 now

@samselikoff
Copy link
Contributor Author

Going through old issues, is this a possibility now?

@tchak
Copy link
Collaborator

tchak commented Jan 26, 2017

Even with babel 6 babel-plugin-lodash may not be trivial to use with ember-cli. My best bet would be to follow the ember-cli tree shaking effort when it's ready.

@lolmaus
Copy link

lolmaus commented Feb 26, 2018

Hi! I'm thinking about an addon with test helpers that would rely on lodash. If the host app does not depend on lodash directly, then my addon should not include lodash in production environment.

I can imagine ember-lodash importing lodash conditionally by checking an option in host app's ember-cli-build.js. This should be trivial to implement?

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

3 participants