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

Error when using passthrough #20

Open
andrew-paterson opened this issue Dec 3, 2024 · 4 comments
Open

Error when using passthrough #20

andrew-paterson opened this issue Dec 3, 2024 · 4 comments

Comments

@andrew-paterson
Copy link

I get the following error if I add passthrough to my server config.

For context this is on an Ember 5.11 app, with ember-mirage. If passthrough is removed, everything works great.

    at eval (webpack://__ember_auto_import__/./node_modules/.pnpm/[email protected]/node_modules/mirage-msw/dist/msw-config.cjs?:61:24)
    at Array.forEach (<anonymous>)
    at createPassthroughRegistry (webpack://__ember_auto_import__/./node_modules/.pnpm/[email protected]/node_modules/mirage-msw/dist/msw-config.cjs?:60:17)
    at PassthroughRegistry.add (webpack://__ember_auto_import__/./node_modules/.pnpm/[email protected]/node_modules/mirage-msw/dist/msw-config.cjs?:86:33)
    at eval (webpack://__ember_auto_import__/./node_modules/.pnpm/[email protected]/node_modules/mirage-msw/dist/msw-config.cjs?:381:27)
    at Array.forEach (<anonymous>)
    at MswConfig.passthrough (webpack://__ember_auto_import__/./node_modules/.pnpm/[email protected]/node_modules/mirage-msw/dist/msw-config.cjs?:376:11)
    at Server.passthrough (webpack://__ember_auto_import__/./node_modules/.pnpm/[email protected]/node_modules/miragejs/dist/mirage.cjs?:6463:35)
    at Server.routes (http://localhost:6202/assets/ember-5-11-0-app.js:755:14)
    at Server.loadConfig (webpack://__ember_auto_import__/./node_modules/.pnpm/[email protected]/node_modules/miragejs/dist/mirage.cjs?:6457:13)```
@IanVS
Copy link
Contributor

IanVS commented Dec 3, 2024

Can you share the code you are using or better yet a minimal reproduction?

@andrew-paterson
Copy link
Author

Sure thing: https://github.com/andrew-paterson/mirage-msw-passthrough

I've managed to work out that Ember is building the app using the require export in package.json, even though mirage-msw is included via an import statement. Thus, the browser is trying to use the code from /dist/msw-config.cjs. I'm not sure why this is, but I've asked about it here.

I created and tested a non Ember app, using a basic webpack config, and that bundled the assets using the correct file (/dist/msw-config.js).

As another test, I also changed the require export in package.json to /dist/msw-config.js for the Ember app and then the error went away.

@IanVS
Copy link
Contributor

IanVS commented Dec 4, 2024

@bgantzler you're an ember user, right? Do you have any insights here?

@cah-brian-gantzler
Copy link
Collaborator

Yes, I am an ember user, but am not using the msw. This seems to be in the build process. based on the above statement that changing the extenstion from .cjs to .js made the error go away it is outside my understanding of how things work. Hoping Ed may have some insight since it appears to be an auto import issue.

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