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

Embroider webpackConfig does not play well with ember-auto-import configurations #699

Open
xg-wang opened this issue Feb 25, 2021 · 3 comments

Comments

@xg-wang
Copy link

xg-wang commented Feb 25, 2021

The alias for ember-auto-import no longer works when I add embroider

    autoImport: {
      alias: {
        marked: 'marked/lib/marked.esm.js',
      },
    },

I'm seeing this error when ember server --prod, notice the serve works in development env ember serve

Uncaught (in promise) Error: an unsupported module was defined, expected `define(id, deps, module)` instead got: `1` arguments to define`
    at o (loader.js:58)
    at define (loader.js:197)
    at Object.<anonymous> (chunk.6c9d15f03ba3931f58bb.js:1)
    at Object.<anonymous> (chunk.6c9d15f03ba3931f58bb.js:1)
    at i (chunk.c21632eff1cb7b13a230.js:1)
    at Module.<anonymous> (chunk.c21632eff1cb7b13a230.js:1)
    at i (chunk.c21632eff1cb7b13a230.js:1)
    at s.callback (chunk.c21632eff1cb7b13a230.js:1)
    at s.exports (loader.js:106)
    at requireModule (loader.js:27)

Repro branch: xg-wang/ember-realworld@2df8c72#diff-e835654135548f75db36136807171b4d12d3514e043f4f80a146b88cc668fba4R11

I can workaround by passing webpack config, my question is should embroider respect alias or webpack config from e-a-i?

    packagerOptions: {
      webpackConfig: {
        resolve: {
          alias: {
            marked: path.resolve(__dirname, 'node_modules/marked/lib/marked.esm.js'),
          },
        },
      },
    },
@xg-wang
Copy link
Author

xg-wang commented Feb 25, 2021

Looks like #662 is about aliasing app's own js, this issue is about importing 3rd party js

@ef4
Copy link
Contributor

ef4 commented Feb 26, 2021

Probably yes, it would be good for embroider to respect the autoImport options. It would do exactly what you're doing manually here.

@jacobq
Copy link

jacobq commented May 18, 2022

Does anyone else think it would be worthwhile to add a few more details about this in the docs? I worked through a little exercise today of getting a native node module (csv-parse) to work in a default ember 4.x app and then make it work in embroider:
https://github.com/jacobq/embroider-csv-parse-test

I found that (1) I basically had to move the ember-auto-import config options over to compatBuild, (2)@embroider/webpack and webpack are not the same -- though I don't really know what the differences are / when to use which except that the former did not have plugins like Webpack.ProvidePlugin, and (3) enabling staticComponents broke the build (presumably because of emberjs/ember-test-helpers#1220).

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