Skip to content

Commit 2424768

Browse files
committed
build: make compiler-sfc global build work
1 parent 67039b3 commit 2424768

File tree

4 files changed

+32
-24
lines changed

4 files changed

+32
-24
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
"devDependencies": {
4444
"@babel/types": "^7.12.0",
4545
"@microsoft/api-extractor": "^7.12.1",
46-
"@rollup/plugin-commonjs": "^17.0.0",
46+
"@rollup/plugin-commonjs": "^18.0.0",
4747
"@rollup/plugin-json": "^4.0.0",
48-
"@rollup/plugin-node-resolve": "^11.0.0",
48+
"@rollup/plugin-node-resolve": "^11.2.1",
4949
"@rollup/plugin-replace": "^2.3.4",
5050
"@types/hash-sum": "^1.0.0",
5151
"@types/jest": "^26.0.16",
@@ -69,6 +69,7 @@
6969
"rollup": "~2.38.5",
7070
"rollup-plugin-node-builtins": "^2.1.2",
7171
"rollup-plugin-node-globals": "^1.4.0",
72+
"rollup-plugin-node-polyfills": "^0.2.1",
7273
"rollup-plugin-terser": "^7.0.2",
7374
"rollup-plugin-typescript2": "^0.27.2",
7475
"semver": "^7.3.2",

packages/compiler-sfc/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
55
This package contains lower level utilities that you can use if you are writing a plugin / transform for a bundler or module system that compiles Vue Single File Components (SFCs) into JavaScript. It is used in [vue-loader](https://github.com/vuejs/vue-loader), [rollup-plugin-vue](https://github.com/vuejs/rollup-plugin-vue) and [vite](https://github.com/vitejs/vite).
66

7-
## Browser Build Notes
8-
9-
The browser build relies on a browser-bundled build of `postcss` to be available under the global `postcss` (since it can't be properly bundled by Rollup).
10-
117
## API
128

139
The API is intentionally low-level due to the various considerations when integrating Vue SFCs in a build system:

rollup.config.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ function createConfig(format, output, plugins = []) {
119119
const external =
120120
isGlobalBuild || isBrowserESMBuild
121121
? packageOptions.enableNonBrowserBranches
122-
? // externalize postcss for @vue/compiler-sfc
123-
// because @rollup/plugin-commonjs cannot bundle it properly
124-
['postcss']
122+
? []
125123
: // normal browser builds - non-browser only imports are tree-shaken,
126124
// they are only listed here to suppress warnings.
127125
['source-map', '@babel/parser', 'estree-walker']
@@ -141,14 +139,11 @@ function createConfig(format, output, plugins = []) {
141139
const nodePlugins =
142140
packageOptions.enableNonBrowserBranches && format !== 'cjs'
143141
? [
144-
require('@rollup/plugin-node-resolve').nodeResolve({
145-
preferBuiltins: true
146-
}),
147142
require('@rollup/plugin-commonjs')({
148143
sourceMap: false
149144
}),
150-
require('rollup-plugin-node-builtins')(),
151-
require('rollup-plugin-node-globals')()
145+
require('rollup-plugin-node-polyfills')(),
146+
require('@rollup/plugin-node-resolve').nodeResolve()
152147
]
153148
: []
154149

yarn.lock

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,10 @@
559559
"@nodelib/fs.scandir" "2.1.4"
560560
fastq "^1.6.0"
561561

562-
"@rollup/plugin-commonjs@^17.0.0":
563-
version "17.1.0"
564-
resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-17.1.0.tgz#757ec88737dffa8aa913eb392fade2e45aef2a2d"
565-
integrity sha512-PoMdXCw0ZyvjpCMT5aV4nkL0QywxP29sODQsSGeDpr/oI49Qq9tRtAsb/LbYbDzFlOydVEqHmmZWFtXJEAX9ew==
562+
"@rollup/plugin-commonjs@^18.0.0":
563+
version "18.0.0"
564+
resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-18.0.0.tgz#50dc7518b5aa9e66a270e529ea85115d269825c4"
565+
integrity sha512-fj92shhg8luw7XbA0HowAqz90oo7qtLGwqTKbyZ8pmOyH8ui5e+u0wPEgeHLH3djcVma6gUCUrjY6w5R2o1u6g==
566566
dependencies:
567567
"@rollup/pluginutils" "^3.1.0"
568568
commondir "^1.0.1"
@@ -579,10 +579,10 @@
579579
dependencies:
580580
"@rollup/pluginutils" "^3.0.8"
581581

582-
"@rollup/plugin-node-resolve@^11.0.0":
583-
version "11.2.0"
584-
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.0.tgz#a5ab88c35bb7622d115f44984dee305112b6f714"
585-
integrity sha512-qHjNIKYt5pCcn+5RUBQxK8krhRvf1HnyVgUCcFFcweDS7fhkOLZeYh0mhHK6Ery8/bb9tvN/ubPzmfF0qjDCTA==
582+
"@rollup/plugin-node-resolve@^11.2.1":
583+
version "11.2.1"
584+
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz#82aa59397a29cd4e13248b106e6a4a1880362a60"
585+
integrity sha512-yc2n43jcqVyGE2sqV5/YCmocy9ArjVAP/BeXyTtADTBBX6V0e5UMqwO8CdQ0kzjb6zu5P1qMzsScCMRvE9OlVg==
586586
dependencies:
587587
"@rollup/pluginutils" "^3.1.0"
588588
"@types/resolve" "1.17.1"
@@ -4617,7 +4617,7 @@ magic-string@^0.22.5:
46174617
dependencies:
46184618
vlq "^0.2.2"
46194619

4620-
magic-string@^0.25.7:
4620+
magic-string@^0.25.3, magic-string@^0.25.7:
46214621
version "0.25.7"
46224622
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051"
46234623
integrity sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==
@@ -6053,6 +6053,15 @@ ripemd160@^2.0.0, ripemd160@^2.0.1:
60536053
hash-base "^3.0.0"
60546054
inherits "^2.0.1"
60556055

6056+
rollup-plugin-inject@^3.0.0:
6057+
version "3.0.2"
6058+
resolved "https://registry.yarnpkg.com/rollup-plugin-inject/-/rollup-plugin-inject-3.0.2.tgz#e4233855bfba6c0c12a312fd6649dff9a13ee9f4"
6059+
integrity sha512-ptg9PQwzs3orn4jkgXJ74bfs5vYz1NCZlSQMBUA0wKcGp5i5pA1AO3fOUEte8enhGUC+iapTCzEWw2jEFFUO/w==
6060+
dependencies:
6061+
estree-walker "^0.6.1"
6062+
magic-string "^0.25.3"
6063+
rollup-pluginutils "^2.8.1"
6064+
60566065
rollup-plugin-node-builtins@^2.1.2:
60576066
version "2.1.2"
60586067
resolved "https://registry.yarnpkg.com/rollup-plugin-node-builtins/-/rollup-plugin-node-builtins-2.1.2.tgz#24a1fed4a43257b6b64371d8abc6ce1ab14597e9"
@@ -6075,6 +6084,13 @@ rollup-plugin-node-globals@^1.4.0:
60756084
process-es6 "^0.11.6"
60766085
rollup-pluginutils "^2.3.1"
60776086

6087+
rollup-plugin-node-polyfills@^0.2.1:
6088+
version "0.2.1"
6089+
resolved "https://registry.yarnpkg.com/rollup-plugin-node-polyfills/-/rollup-plugin-node-polyfills-0.2.1.tgz#53092a2744837164d5b8a28812ba5f3ff61109fd"
6090+
integrity sha512-4kCrKPTJ6sK4/gLL/U5QzVT8cxJcofO0OU74tnB19F40cmuAKSzH5/siithxlofFEjwvw1YAhPmbvGNA6jEroA==
6091+
dependencies:
6092+
rollup-plugin-inject "^3.0.0"
6093+
60786094
rollup-plugin-terser@^7.0.2:
60796095
version "7.0.2"
60806096
resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz#e8fbba4869981b2dc35ae7e8a502d5c6c04d324d"
@@ -6096,7 +6112,7 @@ rollup-plugin-typescript2@^0.27.2:
60966112
resolve "1.17.0"
60976113
tslib "2.0.1"
60986114

6099-
rollup-pluginutils@^2.3.1:
6115+
rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.8.1:
61006116
version "2.8.2"
61016117
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e"
61026118
integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==

0 commit comments

Comments
 (0)