module-alias icon indicating copy to clipboard operation
module-alias copied to clipboard

module-alias not workin with esm

Open its-dibo opened this issue 2 years ago • 4 comments

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

its-dibo avatar Jan 19 '22 09:01 its-dibo

Same here. Any workaround ?

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

package.json

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

fxi avatar Feb 22 '22 14:02 fxi

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.

fxi avatar Feb 22 '22 16:02 fxi

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

its-dibo avatar Feb 22 '22 16:02 its-dibo

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

fxi avatar Feb 22 '22 17:02 fxi