fix: add fullySpecified: false to webpack config for v2 addon index.js resolution - #682
Closed
lifeart wants to merge 1 commit into
Closed
fix: add fullySpecified: false to webpack config for v2 addon index.js resolution#682lifeart wants to merge 1 commit into
lifeart wants to merge 1 commit into
Conversation
Author
|
Closing this PR because it's seems cover same issue we had to fix but from another side: The fullySpecified: false fix:
Our current fix (#683):
They're complementary: Import: 'addon-with-index/components/my-component' Without both fixes:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
fullySpecified: falseto webpack's module rules to support v2 addons that use"type": "module"in their package.json with directory imports.Problem
When a v2 addon uses
"type": "module"inpackage.jsonand has internal imports without explicit/index.jspaths, webpack 5's strict ESM resolution fails to resolve them.Error Case (before fix)
Error message:
BREAKING CHANGE: The request './components/my-component' failed to resolve only because
it was resolved as fully specified (probably because the origin is strict EcmaScript Module,
e.g. a module with javascript mimetype, a '.mjs' file, or a '.js' file where the
package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
Success Case (after fix)
The same addon structure now works correctly:
Solution
Add a webpack module rule that disables strict ESM resolution for .js files: