Skip to content

Commit fb759fc

Browse files
committed
fix: enhance packem configuration with isolated declaration transformer and cjsInterop
- Added isolatedDeclarationTransformer to the packem configuration for better TypeScript support. - Enabled cjsInterop to improve compatibility with CommonJS modules across multiple configurations. - Updated legacyBrowsers and other browser lists to use 'as const' for better type inference in TypeScript.
1 parent 6bb68bb commit fb759fc

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

packages/browserslist-config-anolilab/packem.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { defineConfig } from "@visulima/packem/config";
2+
import isolatedDeclarationTransformer from "@visulima/packem/dts/isolated/transformer/typescript";
23
import transformer from "@visulima/packem/transformer/esbuild";
34

4-
// eslint-disable-next-line import/no-unused-modules
55
export default defineConfig({
6+
cjsInterop: true,
7+
isolatedDeclarationTransformer,
68
rollup: {
79
license: {
810
path: "./LICENSE.md",
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const config = {
2-
legacyBrowsers: ["> 1%", "last 2 versions", "Firefox ESR"],
2+
legacyBrowsers: ["> 1%", "last 2 versions", "Firefox ESR"] as const,
33
modernBrowsers: [
44
"last 2 Chrome versions",
55
"not Chrome < 60",
@@ -11,11 +11,12 @@ const config = {
1111
"not Firefox < 54",
1212
"last 2 Edge versions",
1313
"not Edge < 15",
14-
],
14+
] as const,
15+
1516
/** NOTE: Meaning LTS version. Any version above LTS is not considered as "major release", AFAIK. */
16-
node: ["last 2 node major versions"],
17-
production: ["> 1%", "last 2 versions", "Firefox ESR", "not dead"],
18-
ssr: ["node 22"],
17+
node: ["last 2 node major versions"] as const,
18+
production: ["> 1%", "last 2 versions", "Firefox ESR", "not dead"] as const,
19+
ssr: ["node 22"] as const,
1920
};
2021

2122
export default config;

packages/eslint-config/packem.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { defineConfig } from "@visulima/packem/config";
22
import transformer from "@visulima/packem/transformer/esbuild";
33

44
export default defineConfig({
5+
cjsInterop: true,
56
rollup: {
67
license: {
78
path: "./LICENSE.md",

packages/lint-staged-config/packem.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { defineConfig } from "@visulima/packem/config";
2+
import isolatedDeclarationTransformer from "@visulima/packem/dts/isolated/transformer/typescript";
23
import transformer from "@visulima/packem/transformer/esbuild";
34

45
export default defineConfig({
6+
cjsInterop: true,
7+
isolatedDeclarationTransformer,
58
rollup: {
69
license: {
710
path: "./LICENSE.md",

packages/lint-staged-config/src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ import concatFiles from "./utils/concat-files";
1010
import getNearestConfigPath from "./utils/get-nearest-config-path";
1111

1212
interface StylesheetsConfig {
13-
extensions?: string[];
13+
extensions?: (typeof stylesheetsExtensions)[number][];
1414
}
1515

1616
interface TypescriptConfig {
1717
exclude?: string[];
18-
extensions?: string[];
18+
extensions?: (typeof typescriptExtensions)[number][];
1919
}
2020

21-
export const eslintExtensions = ["cjs", "js", "mjs", "cts", "ts", "mts", "yml", "yaml", "jsx", "tsx", "mdx", "toml", "json", "json5", "jsonc"];
22-
export const typescriptExtensions = ["cts", "ts", "mts", "tsx", "ctsx"];
23-
export const stylesheetsExtensions = ["css", "scss", "sass", "less", "styl", "stylus", "pcss", "postcss", "sss"];
21+
export const eslintExtensions = ["cjs", "js", "mjs", "cts", "ts", "mts", "yml", "yaml", "jsx", "tsx", "mdx", "toml", "json", "json5", "jsonc"] as const;
22+
export const typescriptExtensions = ["cts", "ts", "mts", "tsx", "ctsx"] as const;
23+
export const stylesheetsExtensions = ["css", "scss", "sass", "less", "styl", "stylus", "pcss", "postcss", "sss"] as const;
2424

2525
export const defineConfig = (
2626
options: {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { env, platform } from "node:process";
22

33
// eslint-disable-next-line regexp/no-unused-capturing-group
4-
const isWindows = platform === "win32" || /^(msys|cygwin)$/u.test(env["OSTYPE"] ?? "");
4+
const isWindows: boolean = platform === "win32" || /^(msys|cygwin)$/u.test(env["OSTYPE"] ?? "");
55

66
export default isWindows;

0 commit comments

Comments
 (0)