-
Notifications
You must be signed in to change notification settings - Fork 109
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
Code imported from within addon-test-support dir of addon being included in production build #539
Comments
What precisely do you mean by "vendor file"? There is probably a test-specific vendor chunk, and that would be the correct place for those dependencies to appear. That file shouldn't be loaded by the app except when the app is running its tests. |
I should have mentioned that this is when building for production. Here is the result of
If I move all the contents of the npm package into the addon-test-support dir of the addon itself, remove the npm package as a dependency of the addon and update the imports accordingly (All of which are also in the
The first result includes a 60.26MB chunk which I have confirmed contains all of the test data, originally stored in the npm package. That 60MB chunk is wreaking havoc with the build process, causing the build to give up due to an out-of-memory error, unless I include I was under the impression that I should get the same result either way as I'm importing the data from files within the |
In case it helps, I've reproduced the behaviour in this repo: The README outlines the two scenarios that occur with two different versions of I'm running the app in node |
Regardless of how a project's tests and dependencies are structured, why does ember-auto-import generate a tests chunk when We have a similar situation where using We are using the technique described in this issue to reliably know the name of the test chunk. With a default ember-auto-import configuration it would have a randomly assigned name and I'm not sure how you'd know which chunk is the test chunk without opening the files and parsing their contents. I guess you could also parse index.html and discover it via process of elimination, in some scenarios. But if you pin the name of the file, you can do something like this at the end of ember-cli-build.js: const exclude = environment !== 'production'
? []
: [
'assets/ember-auto-import.tests.js',
'assets/ember-auto-import.tests.map', // probably
];
return new Funnel(app.toTree(), {
exclude,
}); |
I'm using an Ember addon in several Ember apps. The addon has a non-Ember npm package listed as a dependency. This contains a large collection of mocked JSON responses as JavaScript exports, for use in tests.
The
addon-test-support
directory of theember-addon
, has several reusable test modules which import modules fromnpm-package
in order to use as data stubs for tests.These test modules are in turn imported by the test files in the consuming Ember apps.
My understanding is that any import that happens in a file in the
addon-test-support
directory of the addon should be added to the test-support file during a build, but this is not happening.The dependency structure is as follows:
ember-app-1
ember-addon
npm-package
ember-app-2
ember-addon
npm-package
ember-addon
hasember-auto-import
v2.4.2 listed in dependencies andwebpack
v 5.74.0 in `devDependencies.Currently, all of the modules imported from
npm-modules
are being included in the vendor file, even though they are only ever imported from inside theaddon-test-support
directory ofember-addon
.Having read this issue, I have tried moving all the data in
npm-package
inside atest-support
folder, so that all the imports inember-addon
begin withimport x from 'npm-package/test-support
but that didn't help.I tried making
npm-package
adevDependency
ofember-addon
but then trying to build the app gives this error:Is this the expected behaviour, and if so, am I missing something in the docs?
The text was updated successfully, but these errors were encountered: