Skip to content

Commit b1a37b9

Browse files
test: update
1 parent 6eba185 commit b1a37b9

File tree

3 files changed

+38
-36
lines changed

3 files changed

+38
-36
lines changed

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export default async function loader(input, inputMap) {
7575
this.emitWarning(
7676
new Error(
7777
`Failed to parse source map from '${sourceMappingURL}': ${err}`,
78+
{ cause: err },
7879
),
7980
);
8081

src/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ async function fetchFromFilesystem(loaderContext, sourceURL) {
151151
} catch (error) {
152152
throw new Error(
153153
`Failed to parse source map from '${sourceURL}' file: ${error}`,
154+
{ cause: error },
154155
);
155156
}
156157

test/__snapshots__/loader.test.js.snap

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`source-map-loader should add only valid \`sources\` to dependencies: code 1`] = `
44
"// Dependencies
@@ -134,6 +134,41 @@ exports[`source-map-loader should process absolute URL in sourceRoot: map 1`] =
134134

135135
exports[`source-map-loader should process absolute URL in sourceRoot: warnings 1`] = `[]`;
136136

137+
exports[`source-map-loader should process css sourceMap and skip source content: code 1`] = `
138+
"// Skip SourcesContent in SourceMap
139+
// comment
140+
"
141+
`;
142+
143+
exports[`source-map-loader should process css sourceMap and skip source content: errors 1`] = `[]`;
144+
145+
exports[`source-map-loader should process css sourceMap and skip source content: map 1`] = `
146+
{
147+
"mappings": "AAAA",
148+
"sources": [
149+
"/test/fixtures/normal-file.js - (normalized for test)",
150+
"unresolved-file.js",
151+
"/test/fixtures/normal-file2.js - (normalized for test)",
152+
],
153+
"sourcesContent": [
154+
"without SourceMap",
155+
"",
156+
"// without SourceMap
157+
anInvalidDirective = "\\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))))+" */";
158+
// comment
159+
",
160+
],
161+
"version": 3,
162+
}
163+
`;
164+
165+
exports[`source-map-loader should process css sourceMap and skip source content: warnings 1`] = `
166+
[
167+
"ModuleWarning: Module Warning (from \`replaced original path\`):
168+
Failed to parse source map from '/test/fixtures/unresolved-file.js' file: Error: ENOENT: no such file or directory, open '/test/fixtures/unresolved-file.js'",
169+
]
170+
`;
171+
137172
exports[`source-map-loader should process css sourceMap: code 1`] = `
138173
"* {
139174
box-sizing: border-box; }
@@ -159,16 +194,8 @@ exports[`source-map-loader should process css sourceMap: code 1`] = `
159194
"
160195
`;
161196

162-
exports[`source-map-loader should process css sourceMap: code 2`] = `
163-
"// Skip SourcesContent in SourceMap
164-
// comment
165-
"
166-
`;
167-
168197
exports[`source-map-loader should process css sourceMap: errors 1`] = `[]`;
169198

170-
exports[`source-map-loader should process css sourceMap: errors 2`] = `[]`;
171-
172199
exports[`source-map-loader should process css sourceMap: map 1`] = `
173200
{
174201
"file": "app.css",
@@ -210,35 +237,8 @@ exports[`source-map-loader should process css sourceMap: map 1`] = `
210237
}
211238
`;
212239

213-
exports[`source-map-loader should process css sourceMap: map 2`] = `
214-
{
215-
"mappings": "AAAA",
216-
"sources": [
217-
"/test/fixtures/normal-file.js - (normalized for test)",
218-
"unresolved-file.js",
219-
"/test/fixtures/normal-file2.js - (normalized for test)",
220-
],
221-
"sourcesContent": [
222-
"without SourceMap",
223-
"",
224-
"// without SourceMap
225-
anInvalidDirective = "\\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))))+" */";
226-
// comment
227-
",
228-
],
229-
"version": 3,
230-
}
231-
`;
232-
233240
exports[`source-map-loader should process css sourceMap: warnings 1`] = `[]`;
234241

235-
exports[`source-map-loader should process css sourceMap: warnings 2`] = `
236-
[
237-
"ModuleWarning: Module Warning (from \`replaced original path\`):
238-
Failed to parse source map from '/test/fixtures/unresolved-file.js' file: Error: ENOENT: no such file or directory, open '/test/fixtures/unresolved-file.js'",
239-
]
240-
`;
241-
242242
exports[`source-map-loader should process external SourceMaps (external sources): code 1`] = `
243243
"with SourceMap
244244
// comment"

0 commit comments

Comments
 (0)