ember-auto-import icon indicating copy to clipboard operation
ember-auto-import copied to clipboard

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

Open NullVoxPopuli opened this issue 1 year ago • 4 comments

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

Scenario:

  • app/components.foo.hbs: hi
  • app/util/idk.js
    import Foo from '../components/foo';
    
    console.log(Foo);
    

Config:

    autoImport: {
      allowAppImports: ['util/*', 'components/*'],
    },

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

  • example a: https://github.com/NullVoxPopuli/ember-auto-import-repro-appImports-import-other-appImports/commit/3a179e8717116c3b84d746ccb6ed4a2bea411bcb#diff-322f0482bd28fc40f84fcb0aaf208fef7fb63082d462cf02d11f46e59c531c24R6
  • example b: https://github.com/NullVoxPopuli/ember-auto-import-repro-appImports-import-other-appImports/commit/9c9bc4fc97a4d37bbeac7c3a5e260a0ffb1d3904#diff-be9bc2296e644e9cc4c783e51a6a231716c251353aca253effd68264bae589fbR6

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)

NullVoxPopuli avatar Mar 22 '24 17:03 NullVoxPopuli

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

mansona avatar Mar 22 '24 17:03 mansona

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?

NullVoxPopuli avatar Mar 22 '24 17:03 NullVoxPopuli

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

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

vicphase avatar Apr 22 '24 21:04 vicphase

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.

NullVoxPopuli avatar Apr 22 '24 21:04 NullVoxPopuli