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

module-alias not workin with esm #123

Open
its-dibo opened this issue Jan 19, 2022 · 4 comments
Open

module-alias not workin with esm #123

its-dibo opened this issue Jan 19, 2022 · 4 comments

Comments

@its-dibo
Copy link

module-alias is working fine with my commonjs project, once it migrated to use esm it stopped working

minimal repos:
commonjs version
esm version

run npm run start:paths in both projects

@fxi
Copy link

fxi commented Feb 22, 2022

Same here. Any workaround ?

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@root/<xxx>' imported from 'index.js'

package.json

"_moduleAliases": {
    "@root": "."
}

@fxi
Copy link

fxi commented Feb 22, 2022

ok, I replied to this issue as it was the first one to show up, but it turns out that there are many similar issues, the most elaborate that also feature a native solution is this one: #113
I guess this issue could be closed.

@its-dibo
Copy link
Author

ok, I replied to this issue as it was the first one to show up, but it turns out that there are many similar issues, the most elaborate that also feature a native solution is this one: #113 I guess this issue could be closed.

this will force you make some changes to your codebase that introduce breaking change

  1. you will need to change your alias to start with '#'
  2. es6 imports can't refer to a path outside your module i.e a parent director for monorepos

@fxi
Copy link

fxi commented Feb 22, 2022

Thanks
Yep
It's an utter mess and the second point was the last surprise issue I've got

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

2 participants