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

@ember/test-helpers@2 breaks build with mini-css-extract-plugin and ember-auto-import #961

Closed
andreyfel opened this issue Dec 9, 2020 · 16 comments

Comments

@andreyfel
Copy link

We are using mini-css-extract-plugin and ember-auto-import to import styles from fullcalendar@5.
The config looks like this:

    autoImport: {
      webpack: {
        plugins: [
          new MiniCssExtractPlugin({
            filename: 'vendor.css',
          }),
        ],
        module: {
          rules: [{
            test: /\.css$/,
            use: [MiniCssExtractPlugin.loader, 'css-loader'],
          }],
        },
      },
    },

It became possible after this was added to ember-auto-import embroider-build/ember-auto-import#205

It was working fine so far.

I was trying to update our app to ember-qunit@5 and @ember/test-helpers@2. After doing the migration I've started getting the error:

ERROR in ../node_modules/@fullcalendar/daygrid/main.css
Module build failed (from ../node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ../node_modules/mini-css-extract-plugin/dist/loader.js):
Error: Didn't get a result from child compiler
...

If I remove @ember/test-helpers from the package.json the build starts working again. This is why I'm opening the issue against this repo, however, it might be something upstream.

@rwjblue
Copy link
Member

rwjblue commented Dec 10, 2020

Can you make a reproduction? It seems difficult to debug from the error message itself...

@andreyfel
Copy link
Author

Here is the reproduction: https://github.com/andreyfel/mini-css-extract-plugin-with-ember-test-helpers-2-bug
The latest commit won't build.
If you rollback one commit back, it works.

@andreyfel
Copy link
Author

@rwjblue I've tried to update all the dependencies to latest (ember-cli 3.23, ember-auto-import 1.10, etc.) but it didn't help.
See the latest commit in the reproduction repository.

@boris-petrov
Copy link

@rwjblue - we just hit this as well. We're not using mini-css-extract-plugin. Just ember-auto-import with css-loader and style-loader. It's blocking us from updating ember-qunit (and hence @ember/test-helpers).

@mfeckie
Copy link
Contributor

mfeckie commented Jan 9, 2021

Not exactly the same or a repro exactly, I've experience a similar problem.

embroider-build/ember-auto-import#337 (comment) Explains what's happening.

It appears that recent changes cause the parent app the be included twice by ember-auto-import. If you have webpack config for ember-auto-import, this causes problems because it causes webpack to break

@andreyfel
Copy link
Author

@rwjblue sorry to bother you, did you have a chance to look at this issue? It prevents us from upgrading to the latest versions of ember-qunit and test-helpers.

@rwjblue
Copy link
Member

rwjblue commented Jan 18, 2021

Sorry, I haven't had time to dig into it much yet. I still don't fully understand what is going on though, we aren't using any custom / special webpack config in ember-qunit we just rely on ember-auto-import to do its normal thing 🤔.

@mfeckie
Copy link
Contributor

mfeckie commented Jan 18, 2021

@rwjblue I found this information when I looked at what was happening

(from embroider-build/ember-auto-import#337 (comment))
Running into the same problem when upgrading to ember-cli 3.24.

Digging in a bit more, I found this

webpack/webpack#10843 seemed to provide a bit of a clue.

And when I run ember with the debug flags for auto-import, I see this

ember-auto-import:bundler extraWebpackConfig {"module":{"rules":[{"test":{},"use":["style-loader","css-loader"]},{"test":{},"use":["style-loader","css-loader"]}]}} +0ms

So it looks like something is causing the rule to appear twice.

If I look through the process using node debugger, I can see that my ember application ends up in the Set of packages this.options.packages twice.

As far as I can tell, the breakage happens on Ember-CLI 3.24, not on 3.23.

If I remove

    "@ember/test-helpers": "2.0.0",

and pin ember-qunit

-    "ember-qunit": "^5.1.1",
+    "ember-qunit": "4.6.0",

Then the problem goes away.

@boris-petrov
Copy link

@mfeckie - as I mentioned in the other issue, the problem is not in ember-cli. The same issue appears in both 3.23 and 3.24. The problem is somewhere in @ember/test-helpers and/or ember-qunit.

@mfeckie
Copy link
Contributor

mfeckie commented Jan 18, 2021

@boris-petrov I agree, my point was that I started seeing the problem when I upgraded to 3.24 because the blueprint uses @ember/test-helpers and ember-qunit versions where the problem seems to exist

@rwjblue
Copy link
Member

rwjblue commented Feb 19, 2021

Can y'all double check with @ember/[email protected] (published yesterday)?

@boris-petrov
Copy link

@rwjblue - at least for me, the problem is resolved. Thanks!

@andreyfel
Copy link
Author

For some reason, it magically started working! Thanks, @rwjblue!

The only change in this version is this PR: #992

Was it because of es6-promise? (seems unrelated)

I noticed that ember-auto-import was moved from dependencies to devDependencies. Apparently, it fixed our issue here?

ember-auto-import docs say ember-auto-import must be in the dependencies of your addon, not in devDependencies. Otherwise it won't come along when people install your addon..

It would be nice to understand the magic behind this change.

@rwjblue
Copy link
Member

rwjblue commented Feb 19, 2021

I noticed that ember-auto-import was moved from dependencies to devDependencies. Apparently, it fixed our issue here?

Yes, that was what I suspected.

ember-auto-import docs say ember-auto-import must be in the dependencies of your addon, not in devDependencies. Otherwise it won't come along when people install your addon.

These docs are correct, the change in #992 removed the need for us to have ember-auto-import when consumed. We only need ember-auto-import (after #992) to handle our own tests importing of qunit, that is why it is OK to be in devDependencies (which FWIW is how it is in the default new addon blueprint).

@rwjblue rwjblue closed this as completed Feb 19, 2021
@andreyfel
Copy link
Author

I'm wondering why ember-auto-import in dependencies was causing these issues? There are other addons in our app having it in the dependencies and they are not causing such issues.

@achambers
Copy link

Hi folks. I'm finding myself being bitten by the same errors/symptoms I'm seeing in this issue. However, upgrading @ember/test-helpers doesn't seem to be fixing things for me. My setup is ever so slightly different to above, however.

I didn't hit the error when upgrading to [email protected]. My app is on 3.23.1. However, the version of ember-auto-import being used is 1.10.1 which seems to be the version that this error starts to manifest itself.

I have verified that I am also getting the duplicated rules in the ember-auto-import debug out (as per #961 (comment)).

In order to try and update to the supposedly patched test helpers, I did the following:

  1. yarn upgrade ember-qunit --latest
  2. yarn add qunit @ember/test-helper -D

So, unless I misunderstand things, I believe I'm using the patched version of test-helpers that was supposed to fix this bug. However, I'm still experiencing it.

I have tried do document things here embroider-build/ember-auto-import#372

Is anyone here able to give me a steer on how to get past this? Is there any reason why being on 3.23.0 could be a contributing factor here? And would getting to Ember 3.25.x fix this?

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

5 participants