Recovers webpack magic comments and adds to import #1243
Merged
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.
This is my first contribution to snowpack. Please, let me know if there is anything missing from this PR. πββοΈ
Changes
https://github.com/pikapkg/snowpack/blob/b21848be11041ad87656617b6b56a5084023e054/snowpack/src/rewrite-imports.ts#L36
matchDynamicImportValue
strips the magic comments and the result spec is passed to thereplaceImport
handler.The process begins in the
buildFile
method of the build command:https://github.com/pikapkg/snowpack/blob/75ad50315d18d7d4deac0c6efc649b2b650282a8/snowpack/src/commands/build.ts#L195
This PR extracts Webpack's magic comments from dynamic imports before the spec is passed to
matchDynamicImportValue
. If a match is found for these types of comments, they are appended to the rewritten import.Testing
All tests pass locally. The snapshot for
build.test.js
has been updated. Please, review this change as I am not sure if will affect snowpack's treeshaking logic.Docs
No docs were added for this change.