From 6c7a330b3263bd2826e9066d4a2c10450e8b8d21 Mon Sep 17 00:00:00 2001 From: 100pah Date: Thu, 25 Jan 2024 03:26:44 +0800 Subject: [PATCH] fix: (1) fix that some old version bundler (like rollup) do not recognize wildcard that not at the end of the patter string (e.g. "exports: {"./*.js": "xxx"}"). (2) Add readme to package.json. --- package.README.md | 9 +++++++++ package.json | 22 ++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 package.README.md diff --git a/package.README.md b/package.README.md new file mode 100644 index 00000000..2e817e63 --- /dev/null +++ b/package.README.md @@ -0,0 +1,9 @@ +# NOTICE about package.json + +Only `zrender.js` are officially exported to users. + +The other entries listed in the `"exports"` field of `package.json` make the internal files visible, but they are legacy usages, not recommended but not forbidden (for the sake of keeping backward compatible). These entries are made from the search in github about which internal files are imported. + +Since `v5.5.0`, `"type": "module"` and `"exports: {...}"` are added to `package.json`. When upgrading to `v5.5.0+`, if you meet some problems about "can not find/resolve xxx" when importing some internal files, it probably because of the issue "file extension not fully specified". Please try to make the file extension fully specified (that is, `import 'xxx/xxx/xxx.js'` rather than `import 'xxx/xxx/xxx'`), or change the config of you bundler tools to support auto adding file extensions. + +See more details about the `"exports"` field of `package.json` and why it is written like that in https://github.com/apache/echarts/pull/19513 . diff --git a/package.json b/package.json index a779adea..65eec270 100644 --- a/package.json +++ b/package.json @@ -67,9 +67,23 @@ "require": "./dist/zrender.js", "import": "./index.js" }, - "./*.js": "./*.js", - "./*.ts": "./*.ts", - "./*.json": "./*.json", - "./*": "./*.js" + "./lib/canvas/canvas": "./lib/canvas/canvas.js", + "./lib/svg/svg": "./lib/svg/svg.js", + "./lib/vml/vml": "./lib/vml/vml.js", + "./lib/canvas/Painter": "./lib/canvas/Painter.js", + "./lib/svg/Painter": "./lib/svg/Painter.js", + "./lib/svg/patch": "./lib/svg/patch.js", + "./lib/Storage": "./lib/Storage.js", + "./lib/core/util": "./lib/core/util.js", + "./lib/core/env": "./lib/core/env.js", + "./lib/core/Transformable": "./lib/core/Transformable.js", + "./lib/core/BoundingRect": "./lib/core/BoundingRect.js", + "./lib/core/vector": "./lib/core/vector.js", + "./lib/core/bbox": "./lib/core/bbox.js", + "./lib/contain/polygon": "./lib/contain/polygon.js", + "./lib/tool/color": "./lib/tool/color.js", + "./lib/graphic/LinearGradient": "./lib/graphic/LinearGradient.js", + "./lib/graphic/RadialGradient": "./lib/graphic/RadialGradient.js", + "./*": "./*" } } \ No newline at end of file