Description
Describe the bug
The test/sourcemaps/samples/compile-option-dev/test.js
unit test somehow produces different results when you've installed Svelte dependencies with pnpm
vs with npm
. Since I prefer to use pnpm (which can deduplicate packages across node_modules folders from multiple projects, saving a lot of disk space), this means that every time I want to create a Svelte PR, I have to edit that test file and change the expected values in it, then make sure those edits don't make it into my PR.
Reproduction
- Rename
test/sourcemaps/samples/compile-option-dev/
totest/sourcemaps/samples/compile-option-dev.solo/
to run only this test. (This doesn't change the results, just the speed of running the tests) - Run
npm i
, thennpm run test
. - Test passes.
- Run
pnpm import
to convertpackage-lock.json
to apnpm-lock.yaml
file with the same package version numbers in it. - Run
rm -rf node_modules
, thenpnpm i
to ensure that PNPM is the one that has created the node_modules folder - Run
pnpm run test
(ornpm run test
, both will produce the same result) - Test fails: see below.
The test failure is caused by the column numbers produced by SourceMapConsumer.originalPositionFor
from the source-map
package. When that package is installed via npm
, the two column numbers checked for in that test are 5. When the package is installed via pnpm
, the two column numbers are 4 instead of 5. (The logs only show one test failure, on the --done-replace-once
check, but if you edit its column number to expect 4, the --done-replace-twice
check will also fail with actual=4 and expected=5). Logs from a failed test run (running pnpm run test
) are below.
Logs
sourcemaps
1) compile-option-dev.solo
0 passing (66ms)
1 failing
1) sourcemaps
compile-option-dev.solo:
AssertionError [ERR_ASSERTION]: failed to locate "--done-replace-once" from "input.svelte"
+ expected - actual
{
- "column": 4
+ "column": 5
"line": 6
"name": [null]
"source": "input.svelte"
}
at /.../svelte/test/sourcemaps/samples/compile-option-dev.solo/test.js:27:10
at Array.forEach (<anonymous>)
at test (test/sourcemaps/samples/compile-option-dev.solo/test.js:26:3)
at Context.<anonymous> (test/sourcemaps/index.ts:117:4)
ELIFECYCLE Test failed. See above for more details.
System Info
System:
OS: Linux 5.4 Linux Mint 19.1 (Tessa)
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Memory: 8.33 GB / 62.58 GB
Container: Yes
Shell: 4.4.20 - /bin/bash
Binaries:
Node: 16.14.0 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/bin/yarn
npm: 7.23.0 - ~/.local/bin/npm
Browsers:
Chrome: 74.0.3729.169
Firefox: 96.0.3
npmPackages:
rollup: ^1.27.14 => 1.32.1
Severity
annoyance