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

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

Open
NullVoxPopuli opened this issue Mar 22, 2024 · 4 comments

Comments

@NullVoxPopuli
Copy link
Contributor

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

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
Copy link
Member

mansona commented Mar 22, 2024

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

@NullVoxPopuli
Copy link
Contributor Author

NullVoxPopuli commented Mar 22, 2024

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
Copy link

vicphase commented Apr 22, 2024

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
Copy link
Contributor Author

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.

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

3 participants