Skip to content

Commit

Permalink
Merge pull request #1232 from merico-dev/fix-1229
Browse files Browse the repository at this point in the history
chore: fix dayjs plugin bundle problem
  • Loading branch information
GerilLeto authored Oct 10, 2023
2 parents bb2f7ae + 83a2404 commit 400d383
Show file tree
Hide file tree
Showing 10 changed files with 596 additions and 690 deletions.
21 changes: 21 additions & 0 deletions .yarn/patches/dayjs-npm-1.11.9-c47d327b7c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/package.json b/package.json
index 1ebe121c05f9dff3f54bfc95aa4d869046919178..267be7c4561edbe9a2922ab561cfe0bd428dedd9 100644
--- a/package.json
+++ b/package.json
@@ -3,6 +3,16 @@
"version": "1.11.9",
"description": "2KB immutable date time library alternative to Moment.js with the same modern API ",
"main": "dayjs.min.js",
+ "exports": {
+ ".": {
+ "import": "./esm/index.js",
+ "require": "./dayjs.min.js"
+ },
+ "./plugin/*": {
+ "import": "./esm/plugin/*/index.js",
+ "require": "./plugin/*.js"
+ }
+ },
"types": "index.d.ts",
"scripts": {
"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",
2 changes: 1 addition & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"rollup-plugin-visualizer": "5.9.0",
"tabler-icons-react": "^1.48.0",
"typescript": "^4.6.3",
"vite-plugin-static-copy": "0.13.1"
"vite-plugin-static-copy": "^0.17.0"
},
"peerDependencies": {
"@emotion/react": "11.10.6",
Expand Down
2 changes: 1 addition & 1 deletion dashboard/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
Expand Down
32 changes: 24 additions & 8 deletions dashboard/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,29 @@ const EXTERNAL_PATHS = [
'echarts-for-react/lib/core',
'/node_modules/echarts',
'/node_modules/dayjs',
];
const DEPENDENCIES = new Set(Object.keys(dependencies).concat(Object.keys(peerDependencies)));
const externals = (id: string, importer: any, isResolved: boolean) => {
/^dayjs\/plugin/,
/^dayjs$/,
// babel transforms module id of emotion, we need to exclude all of them
if (id.startsWith('@emotion')) {
return true;
/^@emotion/,
];

function shouldExternalize(id: string) {
// check id against external paths
for (const path of EXTERNAL_PATHS) {
if (typeof path === 'string') {
if (id.includes(path)) {
return true;
}
} else if (path.test(id)) {
return true;
}
}
if (EXTERNAL_PATHS.some((p) => id.includes(p))) {
return false;
}

const DEPENDENCIES = new Set(Object.keys(dependencies).concat(Object.keys(peerDependencies)));
const externals = (id: string) => {
if (shouldExternalize(id)) {
return true;
}
return DEPENDENCIES.has(id);
Expand Down Expand Up @@ -61,7 +76,6 @@ export default defineConfig({
react: 'react',
'react/jsx-runtime.js': 'react/jsx-runtime.js',
'reactflow/dist/style.css': 'reactflow/dist/style.css',
'dayjs/plugin': 'dayjs/plugin',
},
},
build: {
Expand All @@ -80,7 +94,9 @@ export default defineConfig({
const ret = GLOBAL_MODULE_IDS[name];
return ret ?? name;
}
const match = EXTERNAL_PATHS.find((p) => name.includes(p));
const match = (EXTERNAL_PATHS.filter((it) => typeof it === 'string') as string[]).find((p) =>
name.includes(p),
);
if (match) {
return match.replace('/node_modules/', '');
}
Expand Down
19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@types/node": "16.11.7",
"@typescript-eslint/eslint-plugin": "5.60.1",
"@typescript-eslint/parser": "5.60.1",
"@vitejs/plugin-react": "^3.1.0",
"@vitejs/plugin-react": "^4.1.0",
"@vitest/ui": "^0.30.1",
"change-case": "^4.1.2",
"eslint": "^8.24.0",
Expand All @@ -37,17 +37,22 @@
"ts-jest": "^29.1.0",
"ts-node": "10.9.1",
"typescript": "5.1.3",
"vite": "4.2.1",
"vite-plugin-dts": "1.4.1",
"vite-tsconfig-paths": "^4.2.0",
"vitest": "^0.30.1"
"vite": "4.4.11",
"vite-plugin-dts": "^3.6.0",
"vite-tsconfig-paths": "^4.2.1"
},
"scripts": {
"prepare": "husky install"
},
"dependencies": {
"@swc/helpers": "~0.5.0",
"tslib": "^2.3.0"
"tslib": "^2.3.0",
"vitest": "^0.34.6"
},
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"resolutions": {
"dayjs@1.11.9": "patch:dayjs@npm%3A1.11.9#./.yarn/patches/dayjs-npm-1.11.9-c47d327b7c.patch",
"dayjs@^1.9.1": "patch:dayjs@npm%3A1.11.9#./.yarn/patches/dayjs-npm-1.11.9-c47d327b7c.patch",
"dayjs@^1.10.4": "patch:dayjs@npm%3A1.11.9#./.yarn/patches/dayjs-npm-1.11.9-c47d327b7c.patch"
}
}
2 changes: 1 addition & 1 deletion settings-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@types/react-grid-layout": "^1.3.2",
"rollup-plugin-visualizer": "5.9.0",
"typescript": "^4.6.3",
"vite-plugin-static-copy": "0.13.1"
"vite-plugin-static-copy": "^0.17.0"
},
"peerDependencies": {
"@emotion/react": "11.10.6",
Expand Down
3 changes: 2 additions & 1 deletion tools/workspace-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function registerProjectTargets(projectFilePath) {
outputs: ['{projectRoot}/dist'],
options: {
cwd: projectDir(),
commands: ['vite build'],
// redirect stderr to stdout
commands: ['vite build 2>&1 | grep -v "TS7056"'],
},
dependsOn: ['^build'],
},
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"typescript": "^4.6.3",
"vite-plugin-static-copy": "0.13.1"
"vite-plugin-static-copy": "^0.17.0"
}
}
2 changes: 1 addition & 1 deletion website/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
Expand Down
Loading

0 comments on commit 400d383

Please sign in to comment.