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

Treeshaking bug: Import module without export #1083

Open
SRoeffaers opened this issue Oct 11, 2018 · 6 comments
Open

Treeshaking bug: Import module without export #1083

SRoeffaers opened this issue Oct 11, 2018 · 6 comments

Comments

@SRoeffaers
Copy link

SRoeffaers commented Oct 11, 2018

When I for examle do this: import 'can/es/can-stache-converters';
It doesn't work when I build it with tree shaking enabled.
When I disable tree shaking, it does work.
I think it can't handle module imports without explicit named imports

@justinbmeyer
Copy link
Contributor

You shouldn’t import this file if you are using tree-shaking. Just import {stashConverters} from “can”

@matthewp
Copy link
Member

There's probably still a bug here worth looking into though.

@SRoeffaers
Copy link
Author

But I won't be doing anything with 'stashConverters'..
It's just needed in the stache-files.
My linter will mark it as an unused variable..

@matthewp
Copy link
Member

matthewp commented Oct 11, 2018

@Kleppo do this:

import { stache, stacheConverters } from 'can';

stache.addConverter(stacheConverters);

@SRoeffaers
Copy link
Author

Ah thx, good idea! :-)

@leoj3n
Copy link

leoj3n commented Oct 22, 2018

I think I've encountered this as well.

My workaround was to, in the context of this example, add to package.json:

"dependencies": {
---snip---
  "can-stache-converters": "*",
---snip---
}

I think this tells steal to include that module, so it doesn't get thrown away during tree shake, but I'm not really sure. The "*" means "any" version, so whatever version of that package included with can. Here are the modules I'm doing this for to avoid the errors that would otherwise appear:

    "can-connect": "*",
    "can-event-dom-enter": "*",
    "can-stache-route-helpers": "*",

Is this actually a solution? Is there a negative to doing this?

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

No branches or pull requests

4 participants