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

Fixed example in the readme #115

Merged
merged 4 commits into from
Aug 16, 2024
Merged

Fixed example in the readme #115

merged 4 commits into from
Aug 16, 2024

Conversation

berti92
Copy link
Contributor

@berti92 berti92 commented Jan 10, 2023

If I use import controllers as mentioned in the README I get the following error:

13:15:21 js.1   |   errors: [
13:15:21 js.1   |     {
13:15:21 js.1   |       detail: undefined,
13:15:21 js.1   |       id: '',
13:15:21 js.1   |       location: {
13:15:21 js.1   |         column: 7,
13:15:21 js.1   |         file: 'application.js',
13:15:21 js.1   |         length: 13,
13:15:21 js.1   |         line: 24,
13:15:21 js.1   |         lineText: 'import "controllers";',
13:15:21 js.1   |         namespace: '',
13:15:21 js.1   |         suggestion: '"./controllers"'
13:15:21 js.1   |       },
13:15:21 js.1   |       notes: [
13:15:21 js.1   |         {
13:15:21 js.1   |           location: null,
13:15:21 js.1   |           text: 'Use the relative path "./controllers" to reference the file "controllers/index.js". Without the leading "./", the path "controllers" is being interpreted as a package path instead.'
13:15:21 js.1   |         }
13:15:21 js.1   |       ],
13:15:21 js.1   |       pluginName: '',
13:15:21 js.1   |       text: 'Could not resolve "controllers"'
13:15:21 js.1   |     }
13:15:21 js.1   |   ],
13:15:21 js.1   |   warnings: []
13:15:21 js.1   | }
13:15:21 js.1   | error Command failed with exit code 1.
13:15:21 js.1   | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
13:15:21 js.1   | exited with code 1

I fixed the error by implementing the suggested "./controllers".

I don't know if the same error occurs with importmap, because I don't use it.

@marcoroth
Copy link
Member

Hey @berti92, thanks for opening this pull request!

Yeah, sadly this is because the different solutions/bundlers are using a different import syntaxes.

Instead of changing it in-place we can maybe say that import "controllers" is for importmaps/webpack(er) and import "./controllers for esbuild.

@berti92
Copy link
Contributor Author

berti92 commented Jan 10, 2023

@marcoroth Thank you, I changed it.

@dhh
Copy link
Member

dhh commented Aug 16, 2024

We already have a section for importmaps that use the correct import syntax for that. We should default to ./controllers for that other section. It's an error that it hadn't been.

@dhh dhh merged commit 6b54a97 into hotwired:main Aug 16, 2024
texpert added a commit to texpert/meetup_website that referenced this pull request Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants