Skip to content

Commit

Permalink
Merged in noissue/remove-webpack-polyfill (pull request #70)
Browse files Browse the repository at this point in the history
remove webpack logic from sync-dynamic-import plugin

Approved-by: Maia Teegarden
  • Loading branch information
jackbrown authored and Maia Teegarden committed Aug 26, 2020
2 parents ece33ef + 1220b4d commit 3d977fc
Showing 1 changed file with 3 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
* ```js
* const mod = import(`${var}/module`)
* ```
*
* webpack prefetch
* ```js
* import(\/* webpackPrefetch: true *\/`${var}/module`)
* ```
*/

module.exports = function({template, types: t}) {
Expand All @@ -50,21 +45,10 @@ module.exports = function({template, types: t}) {
const args = callExpression.get('arguments');
const asyncImport = args[0];
const isString = t.isStringLiteral(asyncImport);
const {value: importSpecifier, leadingComments} = asyncImport.node;
const {value: importSpecifier} = asyncImport.node;

if (
!isString ||
(leadingComments &&
leadingComments.length > 0 &&
leadingComments.some(comment => {
return (
comment.value &&
(comment.value.includes('webpackPrefetch') ||
comment.value.includes('webpackPreload'))
);
}))
) {
// don't rewrite prefetch or preload imports
if (!isString) {
// don't rewrite imports that aren't strings
asyncImport.parentPath.replaceWithMultiple(dummyTemplate());
return;
}
Expand Down

0 comments on commit 3d977fc

Please sign in to comment.