Skip to content

Commit ca26f8c

Browse files
authored
fix(SafariNomoduleFixPlugin): use RawSource instead of a plain object (#6470)
1 parent 3bb2d84 commit ca26f8c

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

Diff for: packages/@vue/cli-service/lib/webpack/SafariNomoduleFixPlugin.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class SafariNomoduleFixPlugin {
2323
if (!needsSafariFix) {
2424
return
2525
}
26+
const { RawSource } = compiler.webpack
27+
? compiler.webpack.sources
28+
: require('webpack-sources')
2629

2730
const ID = 'SafariNomoduleFixPlugin'
2831
compiler.hooks.compilation.tap(ID, compilation => {
@@ -40,14 +43,7 @@ class SafariNomoduleFixPlugin {
4043
// inject the fix as an external script
4144
const safariFixPath = path.join(this.jsDirectory, 'safari-nomodule-fix.js')
4245
const fullSafariFixPath = path.join(compilation.options.output.publicPath, safariFixPath)
43-
compilation.assets[safariFixPath] = {
44-
source: function () {
45-
return Buffer.from(safariFix)
46-
},
47-
size: function () {
48-
return Buffer.byteLength(safariFix)
49-
}
50-
}
46+
compilation.assets[safariFixPath] = new RawSource(safariFix)
5147
scriptTag = {
5248
tagName: 'script',
5349
closeTag: true,

Diff for: packages/@vue/cli-service/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@
8383
},
8484
"peerDependencies": {
8585
"@vue/compiler-sfc": "^3.0.0-beta.14",
86-
"vue-template-compiler": "^2.0.0"
86+
"vue-template-compiler": "^2.0.0",
87+
"webpack-sources": "*"
8788
},
8889
"peerDependenciesMeta": {
8990
"@vue/compiler-sfc": {

0 commit comments

Comments
 (0)