From 787abb2898cd6f19bcbfef089e7fc7497195990f Mon Sep 17 00:00:00 2001 From: xuying <33517362+tangying1027@users.noreply.github.com> Date: Sat, 14 Sep 2024 13:50:16 +0800 Subject: [PATCH] feat: export version (#1996) Co-authored-by: xuying.xu --- package.json | 1 + packages/f2/.fatherrc.js | 10 ++++++++++ packages/f2/src/index.ts | 3 +++ 3 files changed, 14 insertions(+) diff --git a/package.json b/package.json index d0dd33496..cdf621ae8 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "@typescript-eslint/eslint-plugin": "^5.10.0", "@typescript-eslint/parser": "^5.10.0", "adm-zip": "^0.5.10", + "babel-plugin-minify-replace": "^0.5.0", "canvas-to-buffer": "^1.1.1", "cross-env": "^6.0.3", "danger": "^11.2.3", diff --git a/packages/f2/.fatherrc.js b/packages/f2/.fatherrc.js index 34b9cbb08..4aad8e2e0 100644 --- a/packages/f2/.fatherrc.js +++ b/packages/f2/.fatherrc.js @@ -20,6 +20,7 @@ export default process.env.CI && process.env.CI === 'true' // umd: { name: 'F2JSXRuntime', file: 'jsx-runtime' }, // }, }, + typescriptOpts: { tsconfigOverride: { compilerOptions: { @@ -27,5 +28,14 @@ export default process.env.CI && process.env.CI === 'true' }, }, }, + extraBabelPlugins: [['babel-plugin-minify-replace', { + "replacements": [{ + "identifierName": "VERSION", + "replacement": { + "type": "identifier", + "value": JSON.stringify(require('./package').version), + } + }] + }]], extraRollupPlugins: [...(isBundleVis ? [visualizer()] : [])], }; diff --git a/packages/f2/src/index.ts b/packages/f2/src/index.ts index 0353d4a0f..2b7897bf7 100644 --- a/packages/f2/src/index.ts +++ b/packages/f2/src/index.ts @@ -4,3 +4,6 @@ export * from '@antv/f-engine'; export { default as Chart, ChartProps } from './chart'; export { Scale, ScaleConfig } from './deps/f2-scale/src'; export * from './components'; + +//@ts-ignore +export default { version: VERSION };