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 };