Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: preactjs/signals
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0af2c4e7f193e9e56ed840c9129b11501479ec3d
Choose a base ref
..
head repository: preactjs/signals
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 75a34c9ae7505181f97cefdfd87c47a5b169221e
Choose a head ref
Showing with 29 additions and 24 deletions.
  1. +26 −24 karma.conf.js
  2. +3 −0 package.json
50 changes: 26 additions & 24 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -96,8 +96,11 @@ function createEsbuildPlugin() {
return { path: path.join(__dirname, "test/browser/mockFs.js") };
});

// Apply babel pass whenever we load a .js file
// Apply babel pass whenever we load a TS or JS file
build.onLoad({ filter: /\.[mc]?[jt]sx?$/ }, async args => {
// But skip any file from node_modules if we aren't down-leveling
if (!downlevel && args.path.includes("node_modules")) return;

const contents = await fs.readFile(args.path, "utf-8");

// Using a cache is crucial as babel is 30x slower than esbuild
@@ -126,6 +129,7 @@ function createEsbuildPlugin() {
pragmaFrag: "Fragment",
},
];

const ts = [
"@babel/preset-typescript",
{
@@ -141,36 +145,34 @@ function createEsbuildPlugin() {
},
];

const downlevelPlugin = [
"@babel/preset-env",
{
loose: true,
modules: false,
targets: {
browsers: ["last 2 versions", "IE >= 11"],
},
},
];

const coveragePlugin = [
"istanbul",
{
include: minify ? "**/dist/**/*.js" : "**/src/**/*.{ts,js}",
},
];

const tmp = await babel.transformAsync(result, {
filename: args.path,
sourceMaps: "inline",
presets: downlevel
? [
ts,
jsx,
[
"@babel/preset-env",
{
loose: true,
modules: false,
targets: {
browsers: ["last 2 versions", "IE >= 11"],
},
},
],
]
: [ts, jsx],
presets: downlevel ? [ts, jsx, downlevelPlugin] : [ts, jsx],
plugins: [
coverage && [
"istanbul",
{
include: minify ? "**/dist/**/*.js" : "**/src/**/*.{ts,js}",
},
],
coverage && coveragePlugin,
minify && renamePlugin,
].filter(Boolean),
});
result = tmp.code || result;
result = (tmp && tmp.code) || result;
cache.set(args.path, { input: contents, result });

// Fire all pending listeners that are waiting on the same
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -105,5 +105,8 @@
"microbundle@0.15.1": "patches/microbundle@0.15.1.patch",
"@babel/plugin-transform-typescript@7.19.1": "patches/@babel__plugin-transform-typescript@7.19.1.patch"
}
},
"volta": {
"node": "18.18.0"
}
}