embroider-build / ember-auto-import

Zero config import from npm packages
Other
361 stars 110 forks source link

`allowAppImports` entries are now allowed to import from other `allowAppImports` entries. #615

Open NullVoxPopuli opened 3 months ago

NullVoxPopuli commented 3 months ago

Repro: https://github.com/NullVoxPopuli/ember-auto-import-repro-appImports-import-other-appImports

Scenario:

Try to import import './util/idk'; from anywhere

Error:

[test:ember] ERROR in ./app/util/idk.js 2:0-39
[test:ember] Module not found: Error: Can't resolve '../components/foo.js' in '/home/runner/work/ember-auto-import-repro-appImports-import-other-appImports/ember-auto-import-repro-appImports-import-other-appImports/app/util'
[test:ember] resolve '../components/foo.js' in '/home/runner/work/ember-auto-import-repro-appImports-import-other-appImports/ember-auto-import-repro-appImports-import-other-appImports/app/util'
[test:ember]   using description file: /home/runner/work/ember-auto-import-repro-appImports-import-other-appImports/ember-auto-import-repro-appImports-import-other-appImports/package.json (relative path: ./app/util)
mansona commented 3 months ago

does it work using the app name? i.e. import Foo from 'app-name/components/foo' ?

NullVoxPopuli commented 3 months ago

It does not:

Module not found: Error: 
Can't resolve 'app-imports-import-app-imports/components/foo' 
in '/home/nvp/Development/tmp/appImports-import-appImports/app/util'

image

Something interesting I see from this output is:

    aliased with mapping 'app-imports-import-app-imports': '/home/nvp/Development/tmp/appImports-import-appImports/app' to '/home/nvp/Development/tmp/appImports-import-appImports/app/components/foo.js'

which seems like a goofy? idk, or maybe I don't know what it's trying to tell me?

vicphase commented 2 months ago

You're missing this config on your repo in the ember-cli-build.js file

    babel: {
      plugins: [require.resolve('ember-auto-import/babel-plugin')],
    },
NullVoxPopuli commented 2 months ago

Thanks for pointing that out!

after adding that however, I get:

ERROR in ./app/util/idk.js 2:0-39
Module not found: Error: Can't resolve '../components/foo.js' in '/home/nvp/Development/tmp/appImports-import-appImports/app/util'
resolve '../components/foo.js' in '/home/nvp/Development/tmp/appImports-import-appImports/app/util'
  using description file: /home/nvp/Development/tmp/appImports-import-appImports/package.json (relative path: ./app/util)
    Field 'browser' doesn't contain a valid alias configuration

with both absolute and relative import paths, with and without the js extension.