Closed runspired closed 2 weeks ago
I could not replicate locally -- side-effecting imports work as expected in a fresh app.
(@runspired and I are pairing on this though)
current hypothesis is that something has gone very wrong with pnpm + dep management since the lockfile reveals that it is ignoring overrides 🙈
(auto-import and embroider/shared-internals (etc) were not up to date)
Gonna close for now. We can re open if there is a smell of auto-import (2.7.3+) issue later
this branch has the issue: https://github.com/emberjs/data/pull/9479 I've worked around for now by having the test assign the fake export from the side-effect to "this"
also I'm not convinced this is a pnpm issue where we ended up with the wrong auto-import, yes the wrong version is present some places in the project but we didn't narrow down to figuring out if the wrong one was present in the specific test app
I'm running the reproduction and I see the same behavior. But I can see that ember-auto-import did include the module. It's the import statement in the test module that has been deleted.
If you comment out this line, the bug goes away and the side-effectful import remains.
So I think the problem is somewhere in your custom babel plugins.
@ef4 those plugins have already run before this ever occurs, and by commenting them out, all you've done is prevented auto-import and macros from running correctly at all.
I can't reopen this but its definitely not resolved and definitely not the fault of the babel plugins
You could have given me the slightest benefit of the doubt and debugged those babel plugins to confirm, but OK, I did it for you. Here is where they are deleting side-effectful imports:
Most likely that code was intended to be guarded by the if statement above it, but it is not. So it deletes all side-effectful imports.
I have a v2-addon with an entry-point designed to be a side-effect import. The module has
export {}
because some tools will DCE it otherwise, but overall its just a pure side-effect.In the test app of a classic ember-cli app build using latest ember-auto-import and ember-cli I am importing the module in a test file to ensure it correctly performs its side-effect. It is not, because as it turns out the import of this side-effect module is dropped during build.
If I change the code to
import * as foo from 'side-effect-module'; console.log(foo);
the module import will not be dropped.