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
Module alias is not working #154
Comments
Hi @ChuntheQhai! Can you create a simple repro repo for me to look at? |
Here's my repo for ESM with module alias: |
Okay @ChuntheQhai! Making this work is doable. I'm going to make it work with the option |
@ChuntheQhai / @jdalton - did this ever address the issue? I'm trying to make jest work with esm in my setup and it seems having module alias would solve another one of the problems (the last problem would be all those .css / .scss imports)... |
Okay, I updated to latest |
Yes.
Yep. I was just going to post that. It looks like I regressed it when I tried to cache a bit more across loader instances. I'll fix that up tonight 😋 Update: v3.0.11 is released 🎉 |
Okay I see this is fixed for cjs 👍 However, I'm trying to update that simple repo from @ChuntheQhai with the latest esm, but it wouldn't work since the |
|
I wanted to follow up on this - I've forked the simple repro and made it work: |
This comment has been minimized.
This comment has been minimized.
const esmRequire = require('esm')(module, { cjs: { topLevelReturn: true }})
require('module-alias').addAliases({ esmRequire('./logic/demo') |
For me that worked Added "@std/esm": "cjs" to package.json |
If you want to use addAliases in module-alias, you can do this. |
with run esmRequire('module-alias/register') |
This problem has been plaguing me for years because I want to write good quality code that is shared between node & browser.
'nesm.js'
'nesm' shell script
|
I got "Cannot find module" with my @lib on import. Is there way to fix this?
Package.json
Index.js
app.mjs
The text was updated successfully, but these errors were encountered: