Skip to content

Commit 7e49190

Browse files
kingyue737Justineo
authored andcommitted
feat!: inject style via constructable CSSStyleSheet and remove CSP entry (#847)
* chore: not inject inline css on server * feat!: remove csp entry * keep csp title in readme * chore: switch to rolldown and tsdown * update * dedupe * update according to review * emphasize "both" in csp section * load css with unplugin-raw * change tsdown entry
1 parent a6ad4e7 commit 7e49190

12 files changed

+654
-669
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pnpm-lock.yaml
22
demo/data/*.json
3+
src/style.css

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ Static methods can be accessed from [`echarts` itself](https://echarts.apache.or
411411

412412
## CSP: `style-src` or `style-src-elem`
413413

414-
If you are applying a CSP to prevent inline `<style>` injection, you need to use `vue-echarts/csp` instead of `vue-echarts` and include `vue-echarts/csp/style.css` manually.
414+
If you are **both** enforcing a strict CSP that prevents inline `<style>` injection and targeting browsers that don't support the [CSSStyleSheet() constructor](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/CSSStyleSheet#browser_compatibility), you need to manually include `vue-echarts/style.css`.
415415

416416
## Migration to v7
417417

README.zh-Hans.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ Vue-ECharts 允许你通过 Vue 插槽来定义 ECharts 配置中的 [`tooltip.f
411411

412412
## CSP: `style-src``style-src-elem`
413413

414-
如果你正在应用 CSP 来防止内联 `<style>` 注入,则需要使用 `vue-echarts/csp` 代替 `vue-echarts`,并手动引入 `vue-echarts/csp/style.css`
414+
如果你执行严格的 CSP 策略来防止内联 `<style>` 注入,**并且**需要兼容不支持 [CSSStyleSheet() 构造函数](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/CSSStyleSheet#browser_compatibility) 的浏览器,则需要手动引入 `vue-echarts/style.css`
415415

416416
## 迁移到 v7
417417

package.json

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"author": "GU Yiling <[email protected]>",
1111
"scripts": {
1212
"dev": "vite",
13-
"build": "pnpm run docs && rimraf dist && rollup -c",
13+
"build": "pnpm run docs && tsdown",
1414
"typecheck": "tsc",
1515
"lint": "eslint . --fix",
1616
"format": "prettier . --write",
@@ -21,16 +21,15 @@
2121
"docs": "node ./scripts/docs.mjs",
2222
"prepublishOnly": "pnpm run typecheck && pnpm run dev:typecheck && pnpm run build && publint"
2323
},
24-
"packageManager": "pnpm@10.12.4",
24+
"packageManager": "pnpm@10.14.0",
2525
"type": "module",
2626
"main": "dist/index.js",
2727
"unpkg": "dist/index.min.js",
2828
"jsdelivr": "dist/index.min.js",
2929
"types": "dist/index.d.ts",
3030
"exports": {
3131
".": "./dist/index.js",
32-
"./csp": "./dist/csp/index.js",
33-
"./csp/style.css": "./dist/csp/style.css"
32+
"./style.css": "./dist/style.css"
3433
},
3534
"files": [
3635
"dist"
@@ -44,7 +43,7 @@
4443
"@types/node": "^22.15.21",
4544
"@typescript-eslint/utils": "^8.32.1",
4645
"@vercel/analytics": "^1.3.1",
47-
"@vitejs/plugin-vue": "^5.2.4",
46+
"@vitejs/plugin-vue": "^6.0.1",
4847
"@vue/eslint-config-prettier": "^10.2.0",
4948
"@vue/eslint-config-typescript": "^14.5.0",
5049
"@vue/tsconfig": "^0.7.0",
@@ -62,14 +61,11 @@
6261
"postcss-nested": "^7.0.2",
6362
"prettier": "^3.5.3",
6463
"publint": "^0.3.12",
65-
"rimraf": "^6.0.1",
66-
"rollup": "^4.41.1",
67-
"rollup-plugin-dts": "^6.2.1",
68-
"rollup-plugin-esbuild": "^6.2.1",
69-
"rollup-plugin-import-css": "^3.5.8",
64+
"tsdown": "^0.13.2",
7065
"typescript": "^5.8.3",
71-
"vite": "^6.3.5",
66+
"unplugin-raw": "^0.5.0",
67+
"vite": "npm:rolldown-vite@latest",
7268
"vue": "^3.5.13",
73-
"vue-tsc": "^2.2.10"
69+
"vue-tsc": "^3.0.5"
7470
}
7571
}

0 commit comments

Comments
 (0)