Skip to content

Commit

Permalink
build: maps 包添加 umd 产物 (#2407)
Browse files Browse the repository at this point in the history
* build: mpas 包添加 umd 产物

* chore: add changeset

* test: sleepTime
  • Loading branch information
lvisei committed Apr 16, 2024
1 parent fc7459c commit a73f0b6
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-poems-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@antv/l7-maps': patch
---

build: mpas 包添加 umd 产物
4 changes: 3 additions & 1 deletion __tests__/integration/line.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { generateCanvasTestCases } from './utils/generator';
const TEST_CASES = [
{
name: 'arc',
sleepTime: 500,
},
{
name: 'arc_plane',
Expand All @@ -11,10 +12,11 @@ const TEST_CASES = [

{
name: 'flow',
sleepTime: 500,
sleepTime: 800,
},
{
name: 'arc',
sleepTime: 600,
},
{
name: 'dash',
Expand Down
38 changes: 38 additions & 0 deletions packages/maps/.fatherrc.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,48 @@
import type { IFatherConfig } from 'father';
import { defineConfig } from 'father';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';

const isProduction = process.env.NODE_ENV === 'production';

const umdConfig: IFatherConfig['umd'] = {
name: 'L7Maps',
output: {
path: './dist',
filename: 'l7-maps.min.js',
},
platform: 'browser',
targets: { ie: 11 },
externals: {
'mapbox-gl': {
root: 'mapboxgl',
commonjs: 'mapbox-gl',
commonjs2: 'mapbox-gl',
amd: 'mapbox-gl',
},
'maplibre-gl': {
root: 'maplibregl',
commonjs: 'maplibre-gl',
commonjs2: 'maplibre-gl',
amd: 'maplibre-gl',
},
},
chainWebpack(memo) {
// 关闭压缩方便调试,默认开启
// memo.optimization.minimize(false);

// 打包体积分析
memo
.plugin('webpack-bundle-analyzer')
.use(BundleAnalyzerPlugin, [{ analyzerMode: 'static', openAnalyzer: false }]);

return memo;
},
};

export default defineConfig({
extends: '../../.fatherrc.base.ts',
// 使用 babel 编译 esm/cjs 产物,启用 transform-import-css-l7 插件完成 CSS 内联打包
esm: { transformer: 'babel' },
cjs: isProduction ? { transformer: 'babel' } : undefined,
umd: isProduction ? umdConfig : undefined,
});
5 changes: 4 additions & 1 deletion packages/maps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
"**/*.css"
],
"main": "lib/index.js",
"unpkg": "dist/l7-maps.min.js",
"module": "es/index.js",
"types": "es/index.d.ts",
"files": [
"dist",
"lib",
"es"
"es",
"!dist/report.html"
],
"scripts": {
"dev": "father dev",
Expand Down

0 comments on commit a73f0b6

Please sign in to comment.