Skip to content

Commit

Permalink
fix(babel): fixed esm detection in node_modules (#1245, fixes #1242)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anber committed May 5, 2023
1 parent 54ab61b commit 821a681
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-eagles-burn.md
@@ -0,0 +1,5 @@
---
'@linaria/babel-preset': patch
---

Better support for ES-modules in node_modules (fixes #1242)
2 changes: 1 addition & 1 deletion docs/CONFIGURATION.md
Expand Up @@ -208,7 +208,7 @@ module.exports = {
return false;
}
return /(?:^|\n|;)\s*(?:export|import)\s+/.test(code);
return /\b(?:export|import)\b/.test(code);
},
action: require.resolve('@linaria/shaker'),
}
Expand Down
Expand Up @@ -49,7 +49,8 @@ export default function loadLinariaOptions(
return false;
}

return /(?:^|\n|;)\s*(?:export|import)\s+/.test(code);
// If a file contains `export` or `import` keywords, we assume it's an ES-module
return /\b(?:export|import)\b/.test(code);
},
action: require.resolve('@linaria/shaker'),
},
Expand Down

0 comments on commit 821a681

Please sign in to comment.