Skip to content

Commit

Permalink
build: 支持node 16
Browse files Browse the repository at this point in the history
  • Loading branch information
roymondchen authored and jia000 committed Jun 1, 2022
1 parent e0f8752 commit efef69e
Show file tree
Hide file tree
Showing 14 changed files with 2,686 additions and 449 deletions.
2 changes: 2 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"vue",
"react",
"react-dom",
"vue-template-compiler",
"@vue/test-utils",
"vite-plugin-vue2",
"element-plus",
"@element-plus/icons",
"@testing-library/vue",
Expand Down
2 changes: 1 addition & 1 deletion magic-admin/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ npm i lerna -g
# magic依赖安装和构建
cd ${WORKSPACE}
npm run reinstall
npm run build
# npm run build

echo "magic依赖安装完毕 & 打包完毕"

Expand Down
339 changes: 71 additions & 268 deletions package-lock.json

Large diffs are not rendered by default.

44 changes: 40 additions & 4 deletions packages/core/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,48 @@
* limitations under the License.
*/

import { defineConfig } from 'vite';
import path from 'path';

import { getBaseConfig } from '../../vite-config';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';

import pkg from './package.json';

const deps = Object.keys(pkg.dependencies);
export default defineConfig({
plugins: [
dts({
outputDir: 'dist/types',
include: ['src/**/*'],
staticImport: true,
insertTypesEntry: true,
logDiagnostics: true,
}),
],

resolve: {
alias:
process.env.NODE_ENV === 'production'
? []
: [{ find: /^@tmagic\/schema/, replacement: path.join(__dirname, '../schema/src/index.ts') }],
},

build: {
cssCodeSplit: false,
sourcemap: true,
minify: false,
target: 'esnext',

lib: {
entry: 'src/index.ts',
name: 'TMagicCore',
fileName: 'tmagic-core',
},

export default defineConfig(getBaseConfig(deps, 'TMagicCore'));
rollupOptions: {
// 确保外部化处理那些你不想打包进库的依赖
external(id: string) {
return Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id));
},
},
},
});
65 changes: 61 additions & 4 deletions packages/editor/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,69 @@
import path from 'path';

import { defineConfig } from 'vite';

import { getBaseConfig } from '../../vite-config';
import dts from 'vite-plugin-dts';
import vue from '@vitejs/plugin-vue';

import pkg from './package.json';

const deps = Object.keys(pkg.dependencies);
const alias = [{ find: /@editor/, replacement: path.join(__dirname, './src') }];

export default defineConfig(getBaseConfig(deps, 'TMagicEditor', alias));
export default defineConfig({
plugins: [
dts({
outputDir: 'dist/types',
include: ['src/**/*'],
staticImport: true,
insertTypesEntry: true,
logDiagnostics: true,
}),
vue(),
],

resolve: {
alias:
process.env.NODE_ENV === 'production'
? alias
: [
...alias,
{ find: /^@tmagic\/schema/, replacement: path.join(__dirname, '../schema/src/index.ts') },
{ find: /^@tmagic\/utils/, replacement: path.join(__dirname, '../utils/src/index.ts') },
{ find: /^@tmagic\/core/, replacement: path.join(__dirname, '../core/src/index.ts') },
{ find: /^@tmagic\/form/, replacement: path.join(__dirname, '../form/src/index.ts') },
{ find: /^@tmagic\/stage/, replacement: path.join(__dirname, '../stage/src/index.ts') },
],
},

build: {
cssCodeSplit: false,
sourcemap: true,
minify: false,
target: 'esnext',

lib: {
entry: 'src/index.ts',
name: 'TMagicEditor',
fileName: 'tmagic-editor',
},

rollupOptions: {
// 确保外部化处理那些你不想打包进库的依赖
external(id: string) {
return (
/^vue/.test(id) ||
/^element-plus/.test(id) ||
/^@tmagic\//.test(id) ||
Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id))
);
},

output: {
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
globals: {
vue: 'Vue',
'element-plus': 'ElementPlus',
},
},
},
},
});
59 changes: 55 additions & 4 deletions packages/form/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,63 @@
* limitations under the License.
*/

import { defineConfig } from 'vite';
import path from 'path';

import { getBaseConfig } from '../../vite-config';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import vue from '@vitejs/plugin-vue';

import pkg from './package.json';

const deps = Object.keys(pkg.dependencies);
export default defineConfig({
plugins: [
dts({
outputDir: 'dist/types',
include: ['src/**/*'],
staticImport: true,
insertTypesEntry: true,
logDiagnostics: true,
}),
vue(),
],

resolve: {
alias:
process.env.NODE_ENV === 'production'
? []
: [{ find: /^@tmagic\/utils/, replacement: path.join(__dirname, '../utils/src/index.ts') }],
},

build: {
cssCodeSplit: false,
sourcemap: true,
minify: false,
target: 'esnext',

lib: {
entry: 'src/index.ts',
name: 'TMagicForm',
fileName: 'tmagic-form',
},

rollupOptions: {
// 确保外部化处理那些你不想打包进库的依赖
external(id: string) {
return (
/^vue/.test(id) ||
/^element-plus/.test(id) ||
/^@tmagic\//.test(id) ||
Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id))
);
},

export default defineConfig(getBaseConfig(deps, 'TMagicForm'));
output: {
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
globals: {
vue: 'Vue',
'element-plus': 'ElementPlus',
},
},
},
},
});
41 changes: 21 additions & 20 deletions packages/schema/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
/*
* Tencent is pleased to support the open source community by making TMagicEditor available.
*
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';

export default defineConfig({
plugins: [
dts({
outputDir: 'dist/types',
include: ['src/**/*'],
staticImport: true,
insertTypesEntry: true,
logDiagnostics: true,
}),
],

import { getBaseConfig } from '../../vite-config';
build: {
sourcemap: true,

export default defineConfig(getBaseConfig([], 'TMagicSchema'));
lib: {
entry: 'src/index.ts',
name: 'TMagicSchema',
fileName: 'tmagic-schema',
},
},
});
52 changes: 48 additions & 4 deletions packages/stage/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,56 @@
* limitations under the License.
*/

import { defineConfig } from 'vite';
import path from 'path';

import { getBaseConfig } from '../../vite-config';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';

import pkg from './package.json';

const deps = Object.keys(pkg.dependencies);
export default defineConfig({
plugins: [
dts({
outputDir: 'dist/types',
include: ['src/**/*'],
staticImport: true,
insertTypesEntry: true,
logDiagnostics: true,
}),
],

resolve: {
alias:
process.env.NODE_ENV === 'production'
? []
: [
{ find: /^@tmagic\/core/, replacement: path.join(__dirname, '../core/src/index.ts') },
{ find: /^@tmagic\/schema/, replacement: path.join(__dirname, '../schema/src/index.ts') },
{ find: /^@tmagic\/utils/, replacement: path.join(__dirname, '../utils/src/index.ts') },
],
},

build: {
cssCodeSplit: false,
sourcemap: true,
minify: false,
target: 'esnext',

lib: {
entry: 'src/index.ts',
name: 'TMagicStage',
fileName: 'tmagic-stage',
},

export default defineConfig(getBaseConfig(deps, 'TMagicStage'));
rollupOptions: {
// 确保外部化处理那些你不想打包进库的依赖
external(id: string) {
return (
/^vue/.test(id) ||
/^@tmagic\//.test(id) ||
Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id))
);
},
},
},
});
59 changes: 55 additions & 4 deletions packages/table/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,63 @@
* limitations under the License.
*/

import { defineConfig } from 'vite';
import path from 'path';

import { getBaseConfig } from '../../vite-config';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import vue from '@vitejs/plugin-vue';

import pkg from './package.json';

const deps = Object.keys(pkg.dependencies);
export default defineConfig({
plugins: [
dts({
outputDir: 'dist/types',
include: ['src/**/*'],
staticImport: true,
insertTypesEntry: true,
logDiagnostics: true,
}),
vue(),
],

resolve: {
alias:
process.env.NODE_ENV === 'production'
? []
: [{ find: /^@tmagic\/form/, replacement: path.join(__dirname, '../form/src/index.ts') }],
},

build: {
cssCodeSplit: false,
sourcemap: true,
minify: false,
target: 'esnext',

lib: {
entry: 'src/index.ts',
name: 'TMagicTable',
fileName: 'tmagic-table',
},

rollupOptions: {
// 确保外部化处理那些你不想打包进库的依赖
external(id: string) {
return (
/^vue/.test(id) ||
/^element-plus/.test(id) ||
/^@tmagic\//.test(id) ||
Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id))
);
},

export default defineConfig(getBaseConfig(deps, 'TMagicTable'));
output: {
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
globals: {
vue: 'Vue',
'element-plus': 'ElementPlus',
},
},
},
},
});
Loading

0 comments on commit efef69e

Please sign in to comment.