Skip to content

Commit

Permalink
fix: add caller settings to loadBabelOptions() (#1356)
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter authored Sep 26, 2023
1 parent 25ba134 commit 727dc2b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .changeset/pretty-mugs-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@linaria/testkit": patch
"@linaria/utils": patch
"webpack5-example": patch
---

fix: add caller settings to loadBabelOptions()
4 changes: 2 additions & 2 deletions examples/webpack4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"version": "0.0.0",
"license": "MIT",
"dependencies": {
"linaria-website": "workspace:^4.1.8"
"linaria-website": "workspace:^"
},
"devDependencies": {
"@babel/core": "^7.18.6",
"@linaria/webpack4-loader": "workspace:^4.1.8",
"@linaria/webpack4-loader": "workspace:^",
"babel-loader": "^8.2.5",
"cross-env": "^7.0.3",
"css-hot-loader": "^1.4.4",
Expand Down
4 changes: 2 additions & 2 deletions examples/webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"license": "MIT",
"main": "index.js",
"dependencies": {
"linaria-website": "workspace:^4.1.8"
"linaria-website": "workspace:^"
},
"devDependencies": {
"@babel/core": "^7.22.15",
"@linaria/webpack5-loader": "workspace:^4.1.8",
"@linaria/webpack5-loader": "workspace:^",
"babel-loader": "^9.1.0",
"cross-env": "^7.0.3",
"css-hot-loader": "^1.4.4",
Expand Down
8 changes: 6 additions & 2 deletions packages/testkit/src/__snapshots__/prepareCode.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
exports[`prepareCode Testing transformation for dynamic-import: code 1`] = `
""use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.foo = foo;
function foo(onImport) {
__linaria_dynamic_import("./foo").then(onImport);
Expand All @@ -17,7 +19,9 @@ exports[`prepareCode Testing transformation for dynamic-import: metadata 1`] = `
exports[`prepareCode Testing transformation for dynamic-import-param: code 1`] = `
""use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.foo = foo;
function foo(locale, onImport) {
__linaria_dynamic_import("./foo/" + locale).then(onImport);
Expand Down
7 changes: 6 additions & 1 deletion packages/testkit/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
"exclude": [
// Contains broken code that should not be type-checked
"src/__fixtures__/prepare-code-test-cases/dynamic-import/input.ts",
"src/__fixtures__/prepare-code-test-cases/dynamic-import-param/input.ts",
"src/__fixtures__/prepare-code-test-cases/for-debug/input.ts",
"src/__fixtures__/linaria-ui-library/types.ts",

"node_modules"
],
"compilerOptions": { "paths": {}, "rootDir": "src/", "types": ["jest", "node"] },
"compilerOptions": {
"paths": {},
"rootDir": "src/",
"types": ["jest", "node"]
},
"references": [
{ "path": "../babel" },
{ "path": "../core" },
Expand Down
10 changes: 9 additions & 1 deletion packages/utils/src/options/loadBabelOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ export default function loadBabelOptions(
babel.loadOptions({
...overrides,
filename,
caller: { name: 'linaria' },
caller: {
name: 'linaria',

// Indicates for @babel/preset-env to support all ESM syntax and avoid transforms before it's needed
supportsStaticESM: true,
supportsDynamicImport: true,
supportsTopLevelAwait: true,
supportsExportNamespaceFrom: true,
},
}) ?? {};

fileCache.set(filename, babelOptions);
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 727dc2b

Please sign in to comment.