@easy-editor/materials-dashboard-geo-map 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,61 @@
1
+ // 自定义插件:处理 echarts 模块的命名导出
2
+ export const echartsExternalPlugin = () => {
3
+ const ECHARTS_MODULES = ['echarts', 'echarts/core', 'echarts/charts', 'echarts/components', 'echarts/renderers']
4
+ const VIRTUAL_PREFIX = '\0virtual:echarts-external:'
5
+
6
+ return {
7
+ name: 'vite-plugin-echarts-external',
8
+ enforce: 'pre',
9
+ resolveId(id) {
10
+ if (ECHARTS_MODULES.includes(id)) {
11
+ return VIRTUAL_PREFIX + id
12
+ }
13
+ return null
14
+ },
15
+ load(id) {
16
+ if (!id.startsWith(VIRTUAL_PREFIX)) {
17
+ return null
18
+ }
19
+ const moduleName = id.slice(VIRTUAL_PREFIX.length)
20
+ const globalKey = moduleName.includes('/') ? `["${moduleName}"]` : `.${moduleName}`
21
+
22
+ return `
23
+ // External module: ${moduleName} -> window${globalKey}
24
+ const mod = window${globalKey} || window.echarts;
25
+ if (!mod) {
26
+ throw new Error('External dependency "${moduleName}" is not available on window.');
27
+ }
28
+ export default mod;
29
+ export const {
30
+ ${getExportsForModule(moduleName)}
31
+ } = mod;
32
+ `
33
+ },
34
+ }
35
+ }
36
+
37
+ // 根据模块名返回需要导出的属性
38
+ function getExportsForModule(moduleName) {
39
+ switch (moduleName) {
40
+ case 'echarts/core':
41
+ return 'use, init, graphic, registerMap, getMap'
42
+ case 'echarts/charts':
43
+ return 'MapChart, LinesChart, EffectScatterChart, BarChart, LineChart, PieChart, RadarChart, ScatterChart, GaugeChart'
44
+ case 'echarts/components':
45
+ return 'GeoComponent, TooltipComponent, LegendComponent, GridComponent, VisualMapComponent, TitleComponent'
46
+ case 'echarts/renderers':
47
+ return 'CanvasRenderer, SVGRenderer'
48
+ default:
49
+ return 'use, init, graphic, registerMap'
50
+ }
51
+ }
52
+
53
+ // echarts 模块列表
54
+ export const ECHARTS_EXTERNALS = ['echarts', 'echarts/core', 'echarts/charts', 'echarts/components', 'echarts/renderers']
55
+ export const ECHARTS_GLOBALS = {
56
+ echarts: 'echarts',
57
+ 'echarts/core': 'echarts',
58
+ 'echarts/charts': 'echarts',
59
+ 'echarts/components': 'echarts',
60
+ 'echarts/renderers': 'echarts',
61
+ }
package/CHANGELOG.md CHANGED
@@ -1,15 +1,21 @@
1
- # @easy-editor/materials-dashboard-geo-map
2
-
3
- ## 0.0.3
4
-
5
- ### Patch Changes
6
-
7
- - perf: configure & datasource
8
- - Updated dependencies
9
- - @easy-editor/materials-shared@0.0.1
10
-
11
- ## 0.0.2
12
-
13
- ### Patch Changes
14
-
15
- - feat: new setters
1
+ # @easy-editor/materials-dashboard-geo-map
2
+
3
+ ## 0.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: component export error
8
+
9
+ ## 0.0.3
10
+
11
+ ### Patch Changes
12
+
13
+ - perf: configure & datasource
14
+ - Updated dependencies
15
+ - @easy-editor/materials-shared@0.0.1
16
+
17
+ ## 0.0.2
18
+
19
+ ### Patch Changes
20
+
21
+ - feat: new setters
@@ -2,9 +2,18 @@
2
2
  * @easy-editor/easypack configuration
3
3
  * @type {import('@easy-editor/easypack').EasypackConfig}
4
4
  */
5
+ import { ECHARTS_EXTERNALS, ECHARTS_GLOBALS, echartsExternalPlugin } from './.vite/echarts-external-plugin'
6
+
5
7
  export default {
6
8
  preset: 'material',
7
9
  dev: {
8
10
  port: 5001,
9
11
  },
12
+ rollup: {
13
+ external: ECHARTS_EXTERNALS,
14
+ output: {
15
+ globals: ECHARTS_GLOBALS,
16
+ },
17
+ },
18
+ vitePlugins: [echartsExternalPlugin()],
10
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easy-editor/materials-dashboard-geo-map",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Geo Map component for EasyEditor dashboard",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",