-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Ensure patched merge-source-map is included in package (#24490)
- Loading branch information
1 parent
5a7dda8
commit 493d90c
Showing
6 changed files
with
121 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// https://github.com/keik/merge-source-map | ||
// | ||
// The MIT License (MIT) | ||
|
||
// Copyright (c) keik <[email protected]> | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import sourceMap from 'source-map' | ||
|
||
const SourceMapConsumer = sourceMap.SourceMapConsumer | ||
const SourceMapGenerator = sourceMap.SourceMapGenerator | ||
|
||
/** | ||
* Merge old source map and new source map and return merged. | ||
* If old or new source map value is falsy, return another one as it is. | ||
* | ||
* @param {object|string} [oldMap] old source map object | ||
* @param {object|string} [newmap] new source map object | ||
* @return {object|undefined} merged source map object, or undefined when both old and new source map are undefined | ||
*/ | ||
export default function merge (oldMap, newMap) { | ||
if (!oldMap) return newMap | ||
|
||
if (!newMap) return oldMap | ||
|
||
const oldMapConsumer = new SourceMapConsumer(oldMap) | ||
const newMapConsumer = new SourceMapConsumer(newMap) | ||
const mergedMapGenerator = new SourceMapGenerator() | ||
|
||
// iterate on new map and overwrite original position of new map with one of old map | ||
newMapConsumer.eachMapping(function (m) { | ||
// pass when `originalLine` is null. | ||
// It occurs in case that the node does not have origin in original code. | ||
if (m.originalLine == null) return | ||
|
||
const origPosInOldMap = oldMapConsumer.originalPositionFor({ | ||
line: m.originalLine, | ||
column: m.originalColumn, | ||
}) | ||
|
||
if (origPosInOldMap.source == null) return | ||
|
||
mergedMapGenerator.addMapping({ | ||
original: { | ||
line: origPosInOldMap.line, | ||
column: origPosInOldMap.column, | ||
}, | ||
generated: { | ||
line: m.generatedLine, | ||
column: m.generatedColumn, | ||
}, | ||
source: origPosInOldMap.source, | ||
name: origPosInOldMap.name, | ||
}) | ||
}) | ||
|
||
const consumers = [newMapConsumer, oldMapConsumer] | ||
|
||
consumers.forEach(function (consumer) { | ||
// @ts-ignore | ||
consumer.sources.forEach(function (sourceFile) { | ||
// @ts-ignore | ||
mergedMapGenerator._sources.add(sourceFile) | ||
const sourceContent = consumer.sourceContentFor(sourceFile) | ||
|
||
if (sourceContent != null) { | ||
mergedMapGenerator.setSourceContent(sourceFile, sourceContent) | ||
} | ||
}) | ||
}) | ||
|
||
// @ts-ignore | ||
mergedMapGenerator._sourceRoot = oldMap.sourceRoot | ||
// @ts-ignore | ||
mergedMapGenerator._file = oldMap.file | ||
|
||
return JSON.parse(mergedMapGenerator.toString()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
npm/webpack-preprocessor/patches/merge-source-map+1.1.0.patch
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7287,9 +7287,9 @@ | |
source-map "^0.6.0" | ||
|
||
"@types/webpack@^4", "@types/webpack@^4.41.12", "@types/webpack@^4.41.21", "@types/webpack@^4.41.8": | ||
version "4.41.32" | ||
resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.41.32.tgz#a7bab03b72904070162b2f169415492209e94212" | ||
integrity sha512-cb+0ioil/7oz5//7tZUSwbrSAN/NWHrQylz5cW8G0dWTcF/g+/dSdMlKVZspBYuMAN1+WnwHrkxiRrLcwd0Heg== | ||
version "4.41.33" | ||
resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.41.33.tgz#16164845a5be6a306bcbe554a8e67f9cac215ffc" | ||
integrity sha512-PPajH64Ft2vWevkerISMtnZ8rTs4YmRbs+23c402J0INmxDKCrhZNvwZYtzx96gY2wAtXdrK1BS2fiC8MlLr3g== | ||
dependencies: | ||
"@types/node" "*" | ||
"@types/tapable" "^1" | ||
|
@@ -8391,10 +8391,10 @@ acorn@^7.0.0, acorn@^7.1.1, acorn@^7.4.0: | |
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" | ||
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== | ||
|
||
acorn@^8.4.1, acorn@^8.5.0: | ||
version "8.7.0" | ||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.0.tgz#90951fde0f8f09df93549481e5fc141445b791cf" | ||
integrity sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ== | ||
acorn@^8.4.1, acorn@^8.5.0, acorn@^8.7.1: | ||
version "8.8.1" | ||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.1.tgz#0a3f9cbecc4ec3bea6f0a80b66ae8dd2da250b73" | ||
integrity sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA== | ||
|
||
[email protected], address@^1.0.1: | ||
version "1.1.2" | ||
|
@@ -15144,10 +15144,10 @@ enhanced-resolve@^4.0.0, enhanced-resolve@^4.1.0, enhanced-resolve@^4.3.0, enhan | |
memory-fs "^0.5.0" | ||
tapable "^1.0.0" | ||
|
||
enhanced-resolve@^5.7.0, enhanced-resolve@^5.9.2: | ||
version "5.9.2" | ||
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.9.2.tgz#0224dcd6a43389ebfb2d55efee517e5466772dd9" | ||
integrity sha512-GIm3fQfwLJ8YZx2smuHpBKkXC1yOk+OBEmKckVyL0i/ea8mqDEykK3ld5dgH1QYPNyT/lIllxV2LULnxCHaHkA== | ||
enhanced-resolve@^5.10.0, enhanced-resolve@^5.7.0, enhanced-resolve@^5.9.2: | ||
version "5.10.0" | ||
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz#0dc579c3bb2a1032e357ac45b8f3a6f3ad4fb1e6" | ||
integrity sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ== | ||
dependencies: | ||
graceful-fs "^4.2.4" | ||
tapable "^2.2.0" | ||
|
@@ -23423,13 +23423,6 @@ [email protected], merge-descriptors@~1.0.0: | |
resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" | ||
integrity sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E= | ||
|
||
[email protected]: | ||
version "1.1.0" | ||
resolved "https://registry.yarnpkg.com/merge-source-map/-/merge-source-map-1.1.0.tgz#2fdde7e6020939f70906a68f2d7ae685e4c8c646" | ||
integrity sha512-Qkcp7P2ygktpMPh2mCQZaf3jhN6D3Z/qVZHSdWvQ+2Ef5HgRAPBO57A77+ENm0CPx2+1Ce/MYKi3ymqdfuqibw== | ||
dependencies: | ||
source-map "^0.6.1" | ||
|
||
merge-stream@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" | ||
|
@@ -34399,10 +34392,10 @@ watchpack@^1.6.0, watchpack@^1.7.4: | |
chokidar "^3.4.1" | ||
watchpack-chokidar2 "^2.0.1" | ||
|
||
watchpack@^2.3.1: | ||
version "2.3.1" | ||
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.3.1.tgz#4200d9447b401156eeca7767ee610f8809bc9d25" | ||
integrity sha512-x0t0JuydIo8qCNctdDrn1OzH/qDzk2+rdCOC3YzumZ42fiMqmQ7T3xQurykYMhYfHaPHTp4ZxAx2NfUo1K6QaA== | ||
watchpack@^2.3.1, watchpack@^2.4.0: | ||
version "2.4.0" | ||
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.0.tgz#fa33032374962c78113f93c7f2fb4c54c9862a5d" | ||
integrity sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg== | ||
dependencies: | ||
glob-to-regexp "^0.4.1" | ||
graceful-fs "^4.1.2" | ||
|
@@ -34731,33 +34724,33 @@ [email protected]: | |
webpack-sources "^1.4.1" | ||
|
||
webpack@^5.38.1: | ||
version "5.72.0" | ||
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.72.0.tgz#f8bc40d9c6bb489a4b7a8a685101d6022b8b6e28" | ||
integrity sha512-qmSmbspI0Qo5ld49htys8GY9XhS9CGqFoHTsOVAnjBdg0Zn79y135R+k4IR4rKK6+eKaabMhJwiVB7xw0SJu5w== | ||
version "5.74.0" | ||
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.74.0.tgz#02a5dac19a17e0bb47093f2be67c695102a55980" | ||
integrity sha512-A2InDwnhhGN4LYctJj6M1JEaGL7Luj6LOmyBHjcI8529cm5p6VXiTIW2sn6ffvEAKmveLzvu4jrihwXtPojlAA== | ||
dependencies: | ||
"@types/eslint-scope" "^3.7.3" | ||
"@types/estree" "^0.0.51" | ||
"@webassemblyjs/ast" "1.11.1" | ||
"@webassemblyjs/wasm-edit" "1.11.1" | ||
"@webassemblyjs/wasm-parser" "1.11.1" | ||
acorn "^8.4.1" | ||
acorn "^8.7.1" | ||
acorn-import-assertions "^1.7.6" | ||
browserslist "^4.14.5" | ||
chrome-trace-event "^1.0.2" | ||
enhanced-resolve "^5.9.2" | ||
enhanced-resolve "^5.10.0" | ||
es-module-lexer "^0.9.0" | ||
eslint-scope "5.1.1" | ||
events "^3.2.0" | ||
glob-to-regexp "^0.4.1" | ||
graceful-fs "^4.2.9" | ||
json-parse-better-errors "^1.0.2" | ||
json-parse-even-better-errors "^2.3.1" | ||
loader-runner "^4.2.0" | ||
mime-types "^2.1.27" | ||
neo-async "^2.6.2" | ||
schema-utils "^3.1.0" | ||
tapable "^2.1.1" | ||
terser-webpack-plugin "^5.1.3" | ||
watchpack "^2.3.1" | ||
watchpack "^2.4.0" | ||
webpack-sources "^3.2.3" | ||
|
||
"webpack@npm:webpack@^5": | ||
|
493d90c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux arm64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
493d90c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin arm64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
493d90c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
493d90c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
win32 x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: