Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(workspace): support npm run link, debug in IM system

dushusir923d22eb55e9
diff --git a/cli/src/templates/base/package.json b/cli/src/templates/base/package.json
index 78a40c41dc..a5a84dc35f 100644
--- a/cli/src/templates/base/package.json
+++ b/cli/src/templates/base/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/cli/src/templates/sheets-plugin/package.json b/cli/src/templates/sheets-plugin/package.json
index 78a40c41dc..a5a84dc35f 100644
--- a/cli/src/templates/sheets-plugin/package.json
+++ b/cli/src/templates/sheets-plugin/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/examples/univer-preact-ts/package.json b/examples/univer-preact-ts/package.json
index 2b9c29f19d..2f76f40f76 100644
--- a/examples/univer-preact-ts/package.json
+++ b/examples/univer-preact-ts/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/examples/univer-vanilla-ts/package.json b/examples/univer-vanilla-ts/package.json
index 1870e952a1..0466d3232e 100644
--- a/examples/univer-vanilla-ts/package.json
+++ b/examples/univer-vanilla-ts/package.json
@@ -10,6 +10,7 @@
"test": "echo \"Error: run tests from root\" && exit 1",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/package.json b/package.json
index ac7f7b032c..48db8a4058 100644
--- a/package.json
+++ b/package.json
@@ -13,6 +13,7 @@
"api": "node scripts/api",
"lighthouse-dev": "start /B node scripts/dev && lighthouse http://127.0.0.1:3103 --output html --output-path ./report.html",
"build": "node scripts/build.js",
+ "link": "node scripts/link.js",
"build:customd": "cd cli/src/templates/univer-custom-build && npm run build:d",
"clean": "npm cache clean --force && pnpm dlx rimraf node_modules **/node_modules/ package-lock.json yarn.lock pnpm-lock.yaml && pnpm install && pnpm dlx playwright install",
"node-server": "node scripts/server.js",
diff --git a/packages/base-component/package.json b/packages/base-component/package.json
index 746f810f1e..fdcad7940f 100644
--- a/packages/base-component/package.json
+++ b/packages/base-component/package.json
@@ -27,6 +27,7 @@
"test:cover": "cross-env NODE_ENV=--experimental-vm-modules jest --coverage",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/base-docs/package.json b/packages/base-docs/package.json
index 8e65fd24e3..b706a83928 100644
--- a/packages/base-docs/package.json
+++ b/packages/base-docs/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/base-formula-engine/package.json b/packages/base-formula-engine/package.json
index c35434215f..006b881566 100644
--- a/packages/base-formula-engine/package.json
+++ b/packages/base-formula-engine/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/base-numfmt-engine/package.json b/packages/base-numfmt-engine/package.json
index daf1892064..44669806c0 100644
--- a/packages/base-numfmt-engine/package.json
+++ b/packages/base-numfmt-engine/package.json
@@ -20,6 +20,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/base-render/package.json b/packages/base-render/package.json
index 6269c4ed2d..bd7a07afb4 100644
--- a/packages/base-render/package.json
+++ b/packages/base-render/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/base-sheets/package.json b/packages/base-sheets/package.json
index 7ec1d9ea96..e40d0099a1 100644
--- a/packages/base-sheets/package.json
+++ b/packages/base-sheets/package.json
@@ -26,6 +26,7 @@
"test:debug": "PWDEBUG=1 npx playwright test",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/base-sheets/src/Controller/ToolBarController.ts b/packages/base-sheets/src/Controller/ToolBarController.ts
index fefd98d610..4fae70ffea 100644
--- a/packages/base-sheets/src/Controller/ToolBarController.ts
+++ b/packages/base-sheets/src/Controller/ToolBarController.ts
@@ -10,7 +10,7 @@ import { LineColor } from '../View/UI/Common/Line/LineColor';
import { SelectionModel } from '../Model';
import { IToolBarItemProps, ToolBarModel } from '../Model/ToolBarModel';
import { ToolBar } from '../View/UI/ToolBar';
-import styles from '../View/UI/toolbar/index.module.less';
+import styles from '../View/UI/ToolBar/index.module.less';
import {
BORDER_LINE_CHILDREN,
FONT_FAMILY_CHILDREN,
diff --git a/packages/base-slides/package.json b/packages/base-slides/package.json
index 0b6025c381..650987fa2a 100644
--- a/packages/base-slides/package.json
+++ b/packages/base-slides/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/common-plugin-collaboration/package.json b/packages/common-plugin-collaboration/package.json
index 835c274fb5..507dec62a1 100644
--- a/packages/common-plugin-collaboration/package.json
+++ b/packages/common-plugin-collaboration/package.json
@@ -26,6 +26,7 @@
"test": "cross-env NODE_ENV=--experimental-vm-modules jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"license": "MIT",
diff --git a/packages/common-plugin-data/package.json b/packages/common-plugin-data/package.json
index 715fd4a30e..7f598d680a 100644
--- a/packages/common-plugin-data/package.json
+++ b/packages/common-plugin-data/package.json
@@ -26,6 +26,7 @@
"test": "cross-env NODE_ENV=--experimental-vm-modules jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"license": "MIT",
diff --git a/packages/core/package.json b/packages/core/package.json
index a5740ffa77..218ee14e5a 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -25,6 +25,7 @@
"test": "cross-env NODE_ENV=--experimental-vm-modules jest --config=jest.config.js",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"api": "node ./api.js",
"tsc": "tsc",
"serve": "node test/Server/server.js"
diff --git a/packages/core/src/Basics/Version.ts b/packages/core/src/Basics/Version.ts
index 9a9e406168..49d7d6e710 100644
--- a/packages/core/src/Basics/Version.ts
+++ b/packages/core/src/Basics/Version.ts
@@ -1,4 +1,4 @@
-import * as pack from '../../package.json';
+import pack from '../../package.json';
/**
* Default env
*/
diff --git a/packages/sheets-plugin-alternating-colors/package.json b/packages/sheets-plugin-alternating-colors/package.json
index aad36d270e..6cb982b130 100644
--- a/packages/sheets-plugin-alternating-colors/package.json
+++ b/packages/sheets-plugin-alternating-colors/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-clipboard/package.json b/packages/sheets-plugin-clipboard/package.json
index b39c2ca1e7..29581c965a 100644
--- a/packages/sheets-plugin-clipboard/package.json
+++ b/packages/sheets-plugin-clipboard/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-comment/package.json b/packages/sheets-plugin-comment/package.json
index 284e57badf..f30fda1818 100644
--- a/packages/sheets-plugin-comment/package.json
+++ b/packages/sheets-plugin-comment/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-conditional-format/package.json b/packages/sheets-plugin-conditional-format/package.json
index 1dae452311..4d5fc06125 100644
--- a/packages/sheets-plugin-conditional-format/package.json
+++ b/packages/sheets-plugin-conditional-format/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-data-validation/package.json b/packages/sheets-plugin-data-validation/package.json
index 048966e895..45dba17edc 100644
--- a/packages/sheets-plugin-data-validation/package.json
+++ b/packages/sheets-plugin-data-validation/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-filter/package.json b/packages/sheets-plugin-filter/package.json
index aaa4ba12b0..9c3cceaca9 100644
--- a/packages/sheets-plugin-filter/package.json
+++ b/packages/sheets-plugin-filter/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-find/package.json b/packages/sheets-plugin-find/package.json
index da5dadfa38..b6841a5351 100644
--- a/packages/sheets-plugin-find/package.json
+++ b/packages/sheets-plugin-find/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-formula/package.json b/packages/sheets-plugin-formula/package.json
index 315b7c1bf5..4ba78ead8c 100644
--- a/packages/sheets-plugin-formula/package.json
+++ b/packages/sheets-plugin-formula/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-freeze/package.json b/packages/sheets-plugin-freeze/package.json
index 005112e735..d0eaad1cd4 100644
--- a/packages/sheets-plugin-freeze/package.json
+++ b/packages/sheets-plugin-freeze/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-group/package.json b/packages/sheets-plugin-group/package.json
index 7ae08a9db3..f144b0e461 100644
--- a/packages/sheets-plugin-group/package.json
+++ b/packages/sheets-plugin-group/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-image/package.json b/packages/sheets-plugin-image/package.json
index abcecfbaa9..728e90d4a0 100644
--- a/packages/sheets-plugin-image/package.json
+++ b/packages/sheets-plugin-image/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-link/package.json b/packages/sheets-plugin-link/package.json
index c08041a156..13278c3e57 100644
--- a/packages/sheets-plugin-link/package.json
+++ b/packages/sheets-plugin-link/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-numfmt/package.json b/packages/sheets-plugin-numfmt/package.json
index cbb87edb6c..a5d2848197 100644
--- a/packages/sheets-plugin-numfmt/package.json
+++ b/packages/sheets-plugin-numfmt/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-pivot-table/package.json b/packages/sheets-plugin-pivot-table/package.json
index 2c45ce33df..ce7af7703a 100644
--- a/packages/sheets-plugin-pivot-table/package.json
+++ b/packages/sheets-plugin-pivot-table/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-print/package.json b/packages/sheets-plugin-print/package.json
index 8fc7376b41..8a9f3c45d9 100644
--- a/packages/sheets-plugin-print/package.json
+++ b/packages/sheets-plugin-print/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-protection/package.json b/packages/sheets-plugin-protection/package.json
index 9615bc6227..9a27869d8a 100644
--- a/packages/sheets-plugin-protection/package.json
+++ b/packages/sheets-plugin-protection/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-screenshot/package.json b/packages/sheets-plugin-screenshot/package.json
index 98aafb6184..3d75a646e9 100644
--- a/packages/sheets-plugin-screenshot/package.json
+++ b/packages/sheets-plugin-screenshot/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-sort/package.json b/packages/sheets-plugin-sort/package.json
index 3b2420e7ca..86aa6ae728 100644
--- a/packages/sheets-plugin-sort/package.json
+++ b/packages/sheets-plugin-sort/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/sheets-plugin-split-column/package.json b/packages/sheets-plugin-split-column/package.json
index 528cb62790..ed4885720a 100644
--- a/packages/sheets-plugin-split-column/package.json
+++ b/packages/sheets-plugin-split-column/package.json
@@ -24,6 +24,7 @@
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/style-universheet/package.json b/packages/style-universheet/package.json
index 07b8c5b3a7..d9739ebe6d 100644
--- a/packages/style-universheet/package.json
+++ b/packages/style-universheet/package.json
@@ -25,6 +25,7 @@
"test:cover": "cross-env NODE_ENV=--experimental-vm-modules jest --coverage",
"dev": "vite",
"build": "tsc && vite build",
+ "link": "pnpm link ./",
"serve": "vite preview"
},
"devDependencies": {
diff --git a/packages/style-universheet/src/Components/Button/Button.tsx b/packages/style-universheet/src/Components/Button/Button.tsx
index fcb778796a..1d08f20832 100644
--- a/packages/style-universheet/src/Components/Button/Button.tsx
+++ b/packages/style-universheet/src/Components/Button/Button.tsx
@@ -1,6 +1,6 @@
import { BaseButtonProps, ButtonComponent, joinClassNames, JSXComponent } from '@univer/base-component';
import { LoadingIcon } from '../Icon';
-import styles from './style/index.module.less';
+import styles from './Style/index.module.less';
// const ButtonTypes: string[] = ['default', 'primary'];
// export type ButtonType = typeof ButtonTypes[number];
diff --git a/scripts/link.js b/scripts/link.js
new file mode 100644
index 0000000000..38196a9655
--- /dev/null
+++ b/scripts/link.js
@@ -0,0 +1,67 @@
+const execa = require('execa');
+// const { targets: allTargets } = require('./util');
+
+const linkTargets = [
+ '@univer/core', // success
+ '@univer/base-render', // success
+ '@univer/base-component', // success
+ '@univer/base-sheets', // success
+
+ '@univer/common-plugin-data',
+ // '@univer/sheets-plugin-format',
+ // '@univer/sheets-plugin-formula',
+
+ // '@univer/sheets-plugin-alternating-colors', // success
+ // '@univer/sheets-plugin-conditional-format', // success
+ // '@univer/sheets-plugin-data-validation', // success
+ // '@univer/sheets-plugin-filter', // success
+ // '@univer/sheets-plugin-find', // success
+ // '@univer/sheets-plugin-freeze', // success
+ // '@univer/sheets-plugin-image', // success
+ // '@univer/sheets-plugin-insert-link', // success
+ // '@univer/sheets-plugin-pivot-table', // success
+ // '@univer/sheets-plugin-print', // success
+ // '@univer/sheets-plugin-protection', // success
+ // '@univer/sheets-plugin-screenshot', // success
+ // '@univer/sheets-plugin-sort', // success
+ // '@univer/sheets-plugin-split-column', // success
+
+ // '@univer/style-google',
+ '@univer/style-universheet', // success
+ // '@univer/style-office365',
+ // '@univer/style-mobile',
+];
+
+// TODO: run => build d.ts => build esm/umd
+
+run();
+
+async function run() {
+ await linkAll(linkTargets);
+}
+// Reference https://github.com/vuejs/vue-next/blob/master/scripts/build.js
+async function linkAll(targets) {
+ await runParallel(require('os').cpus().length, targets, link);
+}
+
+async function runParallel(maxConcurrency, source, iteratorFn) {
+ const ret = [];
+ const executing = [];
+ for (const item of source) {
+ const p = Promise.resolve().then(() => iteratorFn(item));
+ ret.push(p);
+
+ if (maxConcurrency <= source.length) {
+ const e = p.then(() => executing.splice(executing.indexOf(e), 1));
+ executing.push(e);
+ if (executing.length >= maxConcurrency) {
+ await Promise.race(executing);
+ }
+ }
+ }
+ return Promise.all(ret);
+}
+
+async function link(target) {
+ await execa('pnpm', ['run', '--filter', target, 'link'], { stdio: 'inherit' });
+}