Skip to content

Commit

Permalink
build: 统一构建加入runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
roymondchen committed Jan 21, 2025
1 parent 5c0cfe4 commit c524cd4
Show file tree
Hide file tree
Showing 20 changed files with 89 additions and 219 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"packageManager": "[email protected]",
"scripts": {
"bootstrap": "pnpm i && pnpm build",
"clean:top": "rimraf */**/dist */**/types */dist coverage dwt* temp",
"clean:top": "rimraf */**/dist */**/types */dist coverage dwt* temp packages/cli/lib",
"clean:modules": "rimraf node_modules **/node_modules **/**/node_modules",
"clean:all": "pnpm clean:top && pnpm clean:modules",
"lint": "eslint . --ext .js,.vue,.ts,.tsx",
Expand All @@ -17,7 +17,7 @@
"pg:vue2": "pnpm playground:vue2",
"playground:react": "pnpm --filter \"runtime-react\" build:libs && pnpm --filter \"runtime-react\" --filter \"tmagic-playground\" dev:react",
"pg:react": "pnpm playground:react",
"build": "pnpm build:dts && pnpm --filter \"@tmagic/cli\" build && node scripts/build.mjs",
"build": "pnpm build:dts && node scripts/build.mjs",
"build:dts": "pnpm --filter \"@tmagic/cli\" build && tsc -p tsconfig.build-browser.json && vue-tsc --declaration --emitDeclarationOnly --project tsconfig.build-vue.json && rollup -c rollup.dts.config.js && rimraf temp",
"check:type": "tsc --incremental --noEmit -p tsconfig.check.json && vue-tsc --noEmit -p tsconfig.check-vue.json",
"build:playground": "pnpm --filter \"runtime-vue3\" build && pnpm --filter \"tmagic-playground\" build",
Expand Down
31 changes: 0 additions & 31 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 37 additions & 29 deletions rollup.dts.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,49 @@ if (!existsSync('temp')) {
process.exit(1);
}

removeScss('temp/editor/src/index.d.ts');
removeScss('temp/form/src/index.d.ts');
removeScss('temp/design/src/index.d.ts');
removeScss('temp/table/src/index.d.ts');
removeScss('temp/packages/editor/src/index.d.ts');
removeScss('temp/packages/form/src/index.d.ts');
removeScss('temp/packages/design/src/index.d.ts');
removeScss('temp/packages/table/src/index.d.ts');

const packages = readdirSync('temp');
const packages = readdirSync('temp/packages');
const runtimes = readdirSync('temp/runtime');
const targets = process.env.TARGETS ? process.env.TARGETS.split(',') : null;
const targetPackages = targets ? packages.filter((pkg) => targets.includes(pkg)) : packages;

const __dirname = path.dirname(fileURLToPath(import.meta.url));

export default targetPackages.map((pkg) => ({
input: `./temp/${pkg}/src/index.d.ts`,
output: {
file: `packages/${pkg}/types/index.d.ts`,
format: 'es',
},
plugins: [
alias({
entries: [
{ find: /^@form/, replacement: path.join(__dirname, `./temp/form/src`) },
{ find: /^@editor/, replacement: path.join(__dirname, `./temp/editor/src`) },
{ find: /^@data-source/, replacement: path.join(__dirname, `./temp/data-source/src`) },
],
}),
dts(),
],
onwarn(warning, warn) {
// during dts rollup, everything is externalized by default
if (warning.code === 'UNRESOLVED_IMPORT' && !warning.exporter?.startsWith('.')) {
return;
}
warn(warning);
},
}));
function rollupConfig(pkg, base) {
return {
input: `./temp/${base}/${pkg}/src/index.d.ts`,
output: {
file: `${base}/${pkg}/types/index.d.ts`,
format: 'es',
},
plugins: [
alias({
entries: [
{ find: /^@form/, replacement: path.join(__dirname, `./temp/packages/form/src`) },
{ find: /^@editor/, replacement: path.join(__dirname, `./temp/packages/editor/src`) },
{ find: /^@data-source/, replacement: path.join(__dirname, `./temp/packages/data-source/src`) },
],
}),
dts(),
],
onwarn(warning, warn) {
// during dts rollup, everything is externalized by default
if (warning.code === 'UNRESOLVED_IMPORT' && !warning.exporter?.startsWith('.')) {
return;
}
warn(warning);
},
};
}

export default [
...targetPackages.map((pkg) => rollupConfig(pkg, 'packages')),
...runtimes.map((pkg) => rollupConfig(pkg, 'runtime')),
];

function removeScss(path) {
writeFileSync(path, readFileSync(path).toString().replace(`import './theme/index.scss';`, ''));
Expand Down
22 changes: 9 additions & 13 deletions runtime/react-runtime-help/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@
"name": "@tmagic/react-runtime-help",
"type": "module",
"sideEffects": false,
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/tmagic-react-runtime-help.umd.cjs",
"module": "dist/tmagic-react-runtime-help.js",
"types": "types/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
"types": "./types/index.d.ts",
"import": "./dist/tmagic-react-runtime-help.js",
"require": "./dist/tmagic-react-runtime-help.umd.cjs"
},
"./*": "./*"
},
"files": [
"dist"
"dist",
"types"
],
"license": "Apache-2.0",
"scripts": {
"build": "pnpm clean && tsc -b tsconfig.build.json",
"clean": "rimraf dist *.tsbuildinfo",
"check:type": "tsc --noEmit --project tsconfig.build.json"
},
"engines": {
"node": ">=18"
},
Expand Down Expand Up @@ -51,8 +49,6 @@
},
"devDependencies": {
"@types/lodash-es": "^4.17.4",
"@types/node": "^18.19.0",
"@types/react": "^18.3.3",
"rimraf": "^3.0.2"
"@types/react": "^18.3.3"
}
}
11 changes: 0 additions & 11 deletions runtime/react-runtime-help/tsconfig.build.json

This file was deleted.

1 change: 0 additions & 1 deletion runtime/react-runtime-help/tsconfig.build.tsbuildinfo

This file was deleted.

9 changes: 0 additions & 9 deletions runtime/react-runtime-help/tsconfig.json

This file was deleted.

14 changes: 0 additions & 14 deletions runtime/tmagic-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
"types"
],
"license": "Apache-2.0",
"scripts": {
"build": "npm run build:type && vite build",
"build:type": "npm run clear:type && vue-tsc --declaration --emitDeclarationOnly --project tsconfig.build.json",
"clear:type": "rimraf ./types",
"type:check": "vue-tsc --noEmit"
},
"engines": {
"node": ">=18"
},
Expand All @@ -45,13 +39,5 @@
"typescript": {
"optional": true
}
},
"devDependencies": {
"@types/node": "^18.19.0",
"@vitejs/plugin-vue": "^5.2.1",
"@vue/compiler-sfc": "^3.5.13",
"rimraf": "^3.0.2",
"vite": "^6.0.10",
"vue-tsc": "^2.2.0"
}
}
13 changes: 0 additions & 13 deletions runtime/tmagic-form/tsconfig.build.json

This file was deleted.

6 changes: 0 additions & 6 deletions runtime/tmagic-form/tsconfig.json

This file was deleted.

45 changes: 0 additions & 45 deletions runtime/tmagic-form/vite.config.ts

This file was deleted.

22 changes: 9 additions & 13 deletions runtime/vue-runtime-help/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@
"name": "@tmagic/vue-runtime-help",
"type": "module",
"sideEffects": false,
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/tmagic-vue-runtime-help.umd.cjs",
"module": "dist/tmagic-vue-runtime-help.js",
"types": "types/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
"types": "./types/index.d.ts",
"import": "./dist/tmagic-vue-runtime-help.js",
"require": "./dist/tmagic-vue-runtime-help.umd.cjs"
},
"./*": "./*"
},
"files": [
"dist"
"dist",
"types"
],
"license": "Apache-2.0",
"scripts": {
"build": "pnpm clean && tsc -b tsconfig.build.json",
"clean": "rimraf dist *.tsbuildinfo",
"check:type": "tsc --noEmit --project tsconfig.build.json"
},
"engines": {
"node": ">=18"
},
Expand Down Expand Up @@ -53,8 +51,6 @@
}
},
"devDependencies": {
"@types/node": "^18.19.0",
"@vue/test-utils": "^2.4.6",
"rimraf": "^3.0.2"
"@vue/test-utils": "^2.4.6"
}
}
11 changes: 0 additions & 11 deletions runtime/vue-runtime-help/tsconfig.build.json

This file was deleted.

1 change: 0 additions & 1 deletion runtime/vue-runtime-help/tsconfig.build.tsbuildinfo

This file was deleted.

7 changes: 0 additions & 7 deletions runtime/vue-runtime-help/tsconfig.json

This file was deleted.

Loading

0 comments on commit c524cd4

Please sign in to comment.