Skip to content

Commit 400d383

Browse files
authored
Merge pull request #1232 from merico-dev/fix-1229
chore: fix dayjs plugin bundle problem
2 parents bb2f7ae + 83a2404 commit 400d383

File tree

10 files changed

+596
-690
lines changed

10 files changed

+596
-690
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
diff --git a/package.json b/package.json
2+
index 1ebe121c05f9dff3f54bfc95aa4d869046919178..267be7c4561edbe9a2922ab561cfe0bd428dedd9 100644
3+
--- a/package.json
4+
+++ b/package.json
5+
@@ -3,6 +3,16 @@
6+
"version": "1.11.9",
7+
"description": "2KB immutable date time library alternative to Moment.js with the same modern API ",
8+
"main": "dayjs.min.js",
9+
+ "exports": {
10+
+ ".": {
11+
+ "import": "./esm/index.js",
12+
+ "require": "./dayjs.min.js"
13+
+ },
14+
+ "./plugin/*": {
15+
+ "import": "./esm/plugin/*/index.js",
16+
+ "require": "./plugin/*.js"
17+
+ }
18+
+ },
19+
"types": "index.d.ts",
20+
"scripts": {
21+
"test": "TZ=Pacific/Auckland npm run test-tz && TZ=Europe/London npm run test-tz && TZ=America/Whitehorse npm run test-tz && npm run test-tz && jest",

dashboard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"rollup-plugin-visualizer": "5.9.0",
109109
"tabler-icons-react": "^1.48.0",
110110
"typescript": "^4.6.3",
111-
"vite-plugin-static-copy": "0.13.1"
111+
"vite-plugin-static-copy": "^0.17.0"
112112
},
113113
"peerDependencies": {
114114
"@emotion/react": "11.10.6",

dashboard/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"lib": ["DOM", "DOM.Iterable", "ESNext"],
77
"allowJs": false,
88
"skipLibCheck": true,
9-
"esModuleInterop": false,
9+
"esModuleInterop": true,
1010
"allowSyntheticDefaultImports": true,
1111
"strict": true,
1212
"forceConsistentCasingInFileNames": true,

dashboard/vite.config.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,29 @@ const EXTERNAL_PATHS = [
1919
'echarts-for-react/lib/core',
2020
'/node_modules/echarts',
2121
'/node_modules/dayjs',
22-
];
23-
const DEPENDENCIES = new Set(Object.keys(dependencies).concat(Object.keys(peerDependencies)));
24-
const externals = (id: string, importer: any, isResolved: boolean) => {
22+
/^dayjs\/plugin/,
23+
/^dayjs$/,
2524
// babel transforms module id of emotion, we need to exclude all of them
26-
if (id.startsWith('@emotion')) {
27-
return true;
25+
/^@emotion/,
26+
];
27+
28+
function shouldExternalize(id: string) {
29+
// check id against external paths
30+
for (const path of EXTERNAL_PATHS) {
31+
if (typeof path === 'string') {
32+
if (id.includes(path)) {
33+
return true;
34+
}
35+
} else if (path.test(id)) {
36+
return true;
37+
}
2838
}
29-
if (EXTERNAL_PATHS.some((p) => id.includes(p))) {
39+
return false;
40+
}
41+
42+
const DEPENDENCIES = new Set(Object.keys(dependencies).concat(Object.keys(peerDependencies)));
43+
const externals = (id: string) => {
44+
if (shouldExternalize(id)) {
3045
return true;
3146
}
3247
return DEPENDENCIES.has(id);
@@ -61,7 +76,6 @@ export default defineConfig({
6176
react: 'react',
6277
'react/jsx-runtime.js': 'react/jsx-runtime.js',
6378
'reactflow/dist/style.css': 'reactflow/dist/style.css',
64-
'dayjs/plugin': 'dayjs/plugin',
6579
},
6680
},
6781
build: {
@@ -80,7 +94,9 @@ export default defineConfig({
8094
const ret = GLOBAL_MODULE_IDS[name];
8195
return ret ?? name;
8296
}
83-
const match = EXTERNAL_PATHS.find((p) => name.includes(p));
97+
const match = (EXTERNAL_PATHS.filter((it) => typeof it === 'string') as string[]).find((p) =>
98+
name.includes(p),
99+
);
84100
if (match) {
85101
return match.replace('/node_modules/', '');
86102
}

package.json

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@types/node": "16.11.7",
2424
"@typescript-eslint/eslint-plugin": "5.60.1",
2525
"@typescript-eslint/parser": "5.60.1",
26-
"@vitejs/plugin-react": "^3.1.0",
26+
"@vitejs/plugin-react": "^4.1.0",
2727
"@vitest/ui": "^0.30.1",
2828
"change-case": "^4.1.2",
2929
"eslint": "^8.24.0",
@@ -37,17 +37,22 @@
3737
"ts-jest": "^29.1.0",
3838
"ts-node": "10.9.1",
3939
"typescript": "5.1.3",
40-
"vite": "4.2.1",
41-
"vite-plugin-dts": "1.4.1",
42-
"vite-tsconfig-paths": "^4.2.0",
43-
"vitest": "^0.30.1"
40+
"vite": "4.4.11",
41+
"vite-plugin-dts": "^3.6.0",
42+
"vite-tsconfig-paths": "^4.2.1"
4443
},
4544
"scripts": {
4645
"prepare": "husky install"
4746
},
4847
"dependencies": {
4948
"@swc/helpers": "~0.5.0",
50-
"tslib": "^2.3.0"
49+
"tslib": "^2.3.0",
50+
"vitest": "^0.34.6"
5151
},
52-
"packageManager": "[email protected]"
52+
"packageManager": "[email protected]",
53+
"resolutions": {
54+
"[email protected]": "patch:dayjs@npm%3A1.11.9#./.yarn/patches/dayjs-npm-1.11.9-c47d327b7c.patch",
55+
"dayjs@^1.9.1": "patch:dayjs@npm%3A1.11.9#./.yarn/patches/dayjs-npm-1.11.9-c47d327b7c.patch",
56+
"dayjs@^1.10.4": "patch:dayjs@npm%3A1.11.9#./.yarn/patches/dayjs-npm-1.11.9-c47d327b7c.patch"
57+
}
5358
}

settings-form/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@types/react-grid-layout": "^1.3.2",
4141
"rollup-plugin-visualizer": "5.9.0",
4242
"typescript": "^4.6.3",
43-
"vite-plugin-static-copy": "0.13.1"
43+
"vite-plugin-static-copy": "^0.17.0"
4444
},
4545
"peerDependencies": {
4646
"@emotion/react": "11.10.6",

tools/workspace-plugin/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ function registerProjectTargets(projectFilePath) {
3434
outputs: ['{projectRoot}/dist'],
3535
options: {
3636
cwd: projectDir(),
37-
commands: ['vite build'],
37+
// redirect stderr to stdout
38+
commands: ['vite build 2>&1 | grep -v "TS7056"'],
3839
},
3940
dependsOn: ['^build'],
4041
},

website/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@
8080
"@types/react": "^18.0.0",
8181
"@types/react-dom": "^18.0.0",
8282
"typescript": "^4.6.3",
83-
"vite-plugin-static-copy": "0.13.1"
83+
"vite-plugin-static-copy": "^0.17.0"
8484
}
8585
}

website/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"lib": ["DOM", "DOM.Iterable", "ESNext"],
66
"allowJs": false,
77
"skipLibCheck": true,
8-
"esModuleInterop": false,
8+
"esModuleInterop": true,
99
"allowSyntheticDefaultImports": true,
1010
"strict": true,
1111
"forceConsistentCasingInFileNames": true,

0 commit comments

Comments
 (0)