Skip to content

Commit 3ee87bd

Browse files
committed
breaking: Fully convert to ESM
1 parent ba67455 commit 3ee87bd

12 files changed

+2612
-217
lines changed

.mocharc.cjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
extension: ['js', 'jsx', 'ts', 'tsx'],
3-
spec: ['tests/**.{js,ts,jsx,tsx}'],
4-
loader: 'ts-node/esm'
2+
extension: ["js", "jsx", "ts", "tsx"],
3+
spec: ["tests/**.{js,ts,jsx,tsx}"],
4+
loader: ["ts-node/esm", "babel-register-esm"],
55
};

babel.config.cts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { type ConfigFunction } from "@babel/core";
2+
3+
const config: ConfigFunction = (api) => {
4+
api.cache.forever();
5+
return {
6+
presets: [
7+
["@babel/preset-env", { modules: false, targets: "node 16" }],
8+
["@babel/preset-typescript"],
9+
],
10+
plugins: [
11+
[
12+
"module-extension-resolver",
13+
{
14+
extensionsToKeep: [".json"],
15+
},
16+
],
17+
],
18+
};
19+
};
20+
21+
module.exports = config;

fix-dist-output.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { readdir, rename, rm } from "fs/promises";
2+
import { resolve } from "path";
3+
import { fileURLToPath } from "url";
4+
5+
6+
const __dirname = fileURLToPath(new URL(".", import.meta.url));
7+
const distDir = resolve(__dirname, "dist");
8+
9+
const files = await readdir(distDir);
10+
11+
const configFiles = files.filter((file) => file.includes(".config."));
12+
13+
const srcFiles = await readdir(resolve(distDir, "src"));
14+
15+
await Promise.all(srcFiles.map((file) => rename(resolve(distDir, "src", file), resolve(distDir, file))));
16+
await Promise.all(configFiles.map((file) => rm(resolve(distDir, file))));
17+
await rm(resolve(distDir, "src"), {
18+
recursive: true,
19+
force: true,
20+
});

0 commit comments

Comments
 (0)