mirror of
https://github.com/VisActor/VChart
synced 2024-11-21 23:51:05 +00:00
chore: the babel of bundler should read the targets config
This commit is contained in:
parent
3645d0107f
commit
5ac0d6ff91
@ -11,7 +11,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"rollup": "npm run build",
|
||||
"build": "npm run clear && rollup -c --configPlugin typescript --bundleConfigAsCjs",
|
||||
"build": "npm run clear && rollup -c --configPlugin typescript",
|
||||
"clear": "rimraf lib"
|
||||
},
|
||||
"keywords": [
|
||||
|
@ -17,7 +17,9 @@ let options = defineConfig([
|
||||
],
|
||||
plugins: [
|
||||
resolve(),
|
||||
commonjs(),
|
||||
commonjs({
|
||||
include: './src/vchart/index.js'
|
||||
}),
|
||||
babel({
|
||||
presets: [['@babel/preset-env']],
|
||||
babelHelpers: 'bundled'
|
||||
|
@ -1,10 +1,15 @@
|
||||
import type { PluginItem } from '@babel/core';
|
||||
import type { PluginItem, TransformOptions } from '@babel/core';
|
||||
|
||||
export type BabelPlugins = {
|
||||
presets: PluginItem[];
|
||||
plugins: PluginItem[];
|
||||
};
|
||||
export function getBabelPlugins(packageName: string): BabelPlugins {
|
||||
export function getBabelPlugins(
|
||||
packageName: string,
|
||||
options?: {
|
||||
envOptions?: TransformOptions;
|
||||
}
|
||||
): BabelPlugins {
|
||||
const plugins = [
|
||||
require.resolve('@babel/plugin-proposal-export-default-from'),
|
||||
require.resolve('@babel/plugin-proposal-class-properties'),
|
||||
@ -21,7 +26,7 @@ export function getBabelPlugins(packageName: string): BabelPlugins {
|
||||
|
||||
const presets = [
|
||||
require.resolve('@babel/preset-react'),
|
||||
require.resolve('@babel/preset-env'),
|
||||
[require.resolve('@babel/preset-env'), { targets: 'defaults and not IE 11', ...options?.envOptions }],
|
||||
require.resolve('@babel/preset-typescript')
|
||||
];
|
||||
|
||||
|
@ -16,7 +16,11 @@ function packageNameToPath(name: string) {
|
||||
return name.replace('@', '').replace('/', '_');
|
||||
}
|
||||
export async function buildUmd(config: Config, projectRoot: string, rawPackageJson: RawPackageJson, minify: boolean) {
|
||||
const babelPlugins = getBabelPlugins(rawPackageJson.name);
|
||||
const babelPlugins = getBabelPlugins(rawPackageJson.name, {
|
||||
envOptions: {
|
||||
targets: config.targets
|
||||
}
|
||||
});
|
||||
const entry = path.resolve(
|
||||
projectRoot,
|
||||
config.sourceDir,
|
||||
|
Loading…
Reference in New Issue
Block a user