提交 a79c004d 编写于 作者: C Connor Davis 提交者: Joe Haddad

Remove magic-string (#6772)

* Remove magic-string

* Add back input

* change if statement back

* Fix typo

* remomve useless import
上级 3e7b932b
import MagicString from 'magic-string'
import { Compiler } from 'webpack'
import { SourceMapSource, RawSource } from 'webpack-sources'
import GraphHelpers from 'webpack/lib/GraphHelpers'
......@@ -64,28 +63,16 @@ export class ServerlessPlugin {
input = asset.source()
}
const f = new MagicString(input)
const regex = new RegExp(NEXT_REPLACE_BUILD_ID, 'g')
let result
while ((result = regex.exec(input))) {
f.overwrite(
result.index,
result.index + NEXT_REPLACE_BUILD_ID.length,
this.buildId
)
}
const output = input.replace(NEXT_REPLACE_BUILD_ID, this.buildId)
if (this.sourceMap && inputSourceMap) {
compilation.assets[file] = new SourceMapSource(
f.toString(),
output,
file,
f.generateMap({ hires: true }),
input,
inputSourceMap
)
} else {
compilation.assets[file] = new RawSource(f.toString())
compilation.assets[file] = new RawSource(output)
}
})
}
......
......@@ -63,7 +63,6 @@
"imurmurhash": "0.1.4",
"launch-editor": "2.2.1",
"loader-utils": "1.1.0",
"magic-string": "0.25.2",
"mkdirp": "0.5.1",
"next-server": "8.0.4-canary.20",
"prop-types": "15.6.2",
......
......@@ -8046,13 +8046,6 @@ macos-release@^2.0.0:
resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.0.0.tgz#7dddf4caf79001a851eb4fba7fb6034f251276ab"
integrity sha512-iCM3ZGeqIzlrH7KxYK+fphlJpCCczyHXc+HhRVbEu9uNTCrzYJjvvtefzeKTCVHd5AP/aD/fzC80JZ4ZP+dQ/A==
magic-string@0.25.2:
version "0.25.2"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.2.tgz#139c3a729515ec55e96e69e82a11fe890a293ad9"
integrity sha512-iLs9mPjh9IuTtRsqqhNGYcZXGei0Nh/A4xirrsqW7c+QhKVFL2vm7U09ru6cHRD22azaP/wMDgI+HCqbETMTtg==
dependencies:
sourcemap-codec "^1.4.4"
make-dir@^1.0.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c"
......@@ -11384,11 +11377,6 @@ source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7:
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=
sourcemap-codec@^1.4.4:
version "1.4.4"
resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.4.tgz#c63ea927c029dd6bd9a2b7fa03b3fec02ad56e9f"
integrity sha512-CYAPYdBu34781kLHkaW3m6b/uUSyMOC2R61gcYMWooeuaGtjof86ZA/8T+qVPPt7np1085CR9hmMGrySwEc8Xg==
spawn-sync@^1.0.15:
version "1.0.15"
resolved "https://registry.yarnpkg.com/spawn-sync/-/spawn-sync-1.0.15.tgz#b00799557eb7fb0c8376c29d44e8a1ea67e57476"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册