From c355f9c99912f601b8f71e510f604ad8c0bdf047 Mon Sep 17 00:00:00 2001 From: MiniPear Date: Wed, 27 Sep 2023 16:35:47 +0800 Subject: [PATCH] fix: build --- bundle/g2.full.ts | 5 +++-- bundle/g2.std.ts | 9 +-------- package.json | 4 +++- rollup.config.js | 9 +++++++-- src/index.ts | 12 ++++++++++-- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/bundle/g2.full.ts b/bundle/g2.full.ts index 4594bfa891..5f3eedf486 100644 --- a/bundle/g2.full.ts +++ b/bundle/g2.full.ts @@ -5,6 +5,7 @@ import { geolib, stdlib, threedlib, + autolib, } from '../src/lib'; import { extend, Runtime } from '../src/api'; import { API, CompositionAPI } from '../src/api/extend'; @@ -15,10 +16,10 @@ export * from '../src/exports'; /** * G2 full library initial all the libs, include 3D and auto. */ -const library = { ...stdlib(), ...threedlib() }; +const library = { ...stdlib(), ...autolib(), ...threedlib() }; export const Chart = extend(Runtime, library); export interface Chart extends API {} export interface CompositionNode extends CompositionAPI {} -export { corelib, plotlib, graphlib, geolib, stdlib, threedlib }; +export { corelib, plotlib, graphlib, geolib, stdlib, threedlib, autolib }; diff --git a/bundle/g2.std.ts b/bundle/g2.std.ts index e5542a8d9d..afdcbe034f 100644 --- a/bundle/g2.std.ts +++ b/bundle/g2.std.ts @@ -1,11 +1,4 @@ -import { - corelib, - plotlib, - graphlib, - geolib, - stdlib, - threedlib, -} from '../src/lib'; +import { corelib, plotlib, graphlib, geolib, stdlib } from '../src/lib'; import { extend, Runtime } from '../src/api'; import { API, CompositionAPI } from '../src/api/extend'; import { G2Spec } from '../src/spec'; diff --git a/package.json b/package.json index 135d1b1ddc..6bc27f3fd5 100644 --- a/package.json +++ b/package.json @@ -91,6 +91,7 @@ "@antv/g-webgl": "^1.9.8", "@commitlint/cli": "^11.0.0", "@commitlint/config-conventional": "^17.4.4", + "@optimize-lodash/rollup-plugin": "^4.0.3", "@rollup/plugin-commonjs": "^21.0.2", "@rollup/plugin-node-resolve": "^15.2.1", "@rollup/plugin-terser": "^0.4.3", @@ -122,6 +123,7 @@ "jsdom": "^19.0.0", "limit-size": "^0.1.4", "lint-staged": "^10.5.4", + "lodash-es": "^4.17.21", "npm-run-all": "^4.1.5", "pixelmatch": "5.3.0", "pngjs": "^6.0.0", @@ -163,7 +165,7 @@ }, { "path": "dist/g2.full.min.js", - "limit": "350 Kb", + "limit": "400 Kb", "gzip": true } ], diff --git a/rollup.config.js b/rollup.config.js index b798a62435..0c808c3ec2 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -4,6 +4,8 @@ import terser from '@rollup/plugin-terser'; import commonjs from '@rollup/plugin-commonjs'; import resolve from '@rollup/plugin-node-resolve'; import typescript from 'rollup-plugin-typescript2'; +import json from '@rollup/plugin-json'; +import { optimizeLodashImports } from '@optimize-lodash/rollup-plugin'; const isBundleVis = !!process.env.BUNDLE_VIS; @@ -21,7 +23,8 @@ export default [ treeshake: { preset: 'smallest', // Set `src/exports` as a sideEffects file. - moduleSideEffects: (id, external) => id.includes('src/exports.ts') ? true : false, + moduleSideEffects: (id, external) => + id.includes('src/exports.ts') ? true : false, }, output: [ { @@ -39,8 +42,10 @@ export default [ typescript({ useTsconfigDeclarationDir: true, }), + optimizeLodashImports(), + json(), terser(), ], context: 'window', // Disable 'THIS_IS_UNDEFINED' warnings - })) + })), ]; diff --git a/src/index.ts b/src/index.ts index 2ecc71da2a..153a66b3ec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,17 @@ -import { corelib, plotlib, graphlib, geolib, stdlib, threedlib } from './lib'; +import { + corelib, + plotlib, + graphlib, + geolib, + stdlib, + threedlib, + autolib, +} from './lib'; import { extend, Runtime } from './api'; import { API, CompositionAPI } from './api/extend'; import { G2Spec } from './spec'; -export { corelib, plotlib, graphlib, geolib, stdlib, threedlib }; +export { corelib, plotlib, graphlib, geolib, stdlib, threedlib, autolib }; export * from './exports';