Skip to content

Commit 7fcab17

Browse files
authored
chore!: minimum supported Node.js version is 18.12.0 (#230)
1 parent ac7068f commit 7fcab17

11 files changed

+7313
-15970
lines changed

.github/workflows/nodejs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
strategy:
6161
matrix:
6262
os: [ubuntu-latest, windows-latest, macos-latest]
63-
node-version: [14.x, 16.x, 18.x, 20.x]
63+
node-version: [18.x, 20.x, 21.x]
6464
webpack-version: [latest]
6565

6666
runs-on: ${{ matrix.os }}

babel.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = (api) => {
1010
"@babel/preset-env",
1111
{
1212
targets: {
13-
node: "14.15.0",
13+
node: "18.12.0",
1414
},
1515
},
1616
],

package-lock.json

+7,258-15,918
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"main": "dist/cjs.js",
1515
"engines": {
16-
"node": ">= 14.15.0"
16+
"node": ">= 18.12.0"
1717
},
1818
"scripts": {
1919
"start": "npm run build -- -w",
@@ -48,26 +48,26 @@
4848
"source-map-js": "^1.0.2"
4949
},
5050
"devDependencies": {
51-
"@babel/cli": "^7.23.0",
51+
"@babel/cli": "^7.23.4",
5252
"@babel/core": "^7.23.7",
53-
"@babel/preset-env": "^7.23.7",
54-
"@commitlint/cli": "^17.7.2",
55-
"@commitlint/config-conventional": "^16.2.4",
53+
"@babel/preset-env": "^7.23.8",
54+
"@commitlint/cli": "^18.4.4",
55+
"@commitlint/config-conventional": "^18.4.4",
5656
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
5757
"babel-jest": "^29.7.0",
5858
"cross-env": "^7.0.3",
59-
"cspell": "^6.31.3",
60-
"del": "^6.0.0",
61-
"del-cli": "^4.0.1",
59+
"cspell": "^8.3.2",
60+
"del": "^7.1.0",
61+
"del-cli": "^5.1.0",
6262
"eslint": "^8.50.0",
63-
"eslint-config-prettier": "^8.8.0",
63+
"eslint-config-prettier": "^9.1.0",
6464
"eslint-plugin-import": "^2.28.1",
6565
"husky": "^8.0.3",
6666
"jest": "^29.7.0",
67-
"lint-staged": "^13.3.0",
68-
"memfs": "^3.5.3",
67+
"lint-staged": "^15.2.0",
68+
"memfs": "^4.6.0",
6969
"npm-run-all": "^4.1.5",
70-
"prettier": "^2.8.8",
70+
"prettier": "^3.2.2",
7171
"standard-version": "^9.5.0",
7272
"webpack": "^5.88.2"
7373
},

src/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default async function loader(input, inputMap) {
5454
({ sourceURL, sourceContent } = await fetchFromURL(
5555
this,
5656
this.context,
57-
sourceMappingURL
57+
sourceMappingURL,
5858
));
5959
} catch (error) {
6060
this.emitWarning(error);
@@ -75,8 +75,8 @@ export default async function loader(input, inputMap) {
7575
} catch (parseError) {
7676
this.emitWarning(
7777
new Error(
78-
`Failed to parse source map from '${sourceMappingURL}': ${parseError}`
79-
)
78+
`Failed to parse source map from '${sourceMappingURL}': ${parseError}`,
79+
),
8080
);
8181

8282
callback(null, input, inputMap);
@@ -117,7 +117,7 @@ export default async function loader(input, inputMap) {
117117
context,
118118
source,
119119
map.sourceRoot,
120-
skipReading
120+
skipReading,
121121
));
122122
} catch (error) {
123123
errored = true;
@@ -133,7 +133,7 @@ export default async function loader(input, inputMap) {
133133

134134
// Return original value of `source` when error happens
135135
return { sourceURL: errored ? source : sourceURL, sourceContent };
136-
})
136+
}),
137137
);
138138

139139
const newMap = { ...map };

src/parse-data-url.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function percentDecodeBytes(input) {
8585
} else {
8686
output[outputIndex] = parseInt(
8787
String.fromCodePoint(input[i + 1], input[i + 2]),
88-
16
88+
16,
8989
);
9090
i += 2;
9191
}
@@ -249,7 +249,7 @@ export default function parseDataUrl(stringInput) {
249249

250250
// Can't use /i regexp flag because it isn't restricted to ASCII.
251251
const mimeTypeBase64MatchResult = /(.*); *[Bb][Aa][Ss][Ee]64$/.exec(
252-
mediaType
252+
mediaType,
253253
);
254254

255255
if (mimeTypeBase64MatchResult) {
@@ -362,7 +362,7 @@ export default function parseDataUrl(stringInput) {
362362
if (inputMediaType[positionMediaType] === '"') {
363363
[parameterValue, positionMediaType] = collectAnHTTPQuotedString(
364364
inputMediaType,
365-
positionMediaType
365+
positionMediaType,
366366
);
367367

368368
while (

src/utils.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const sourceMappingURLRegex = RegExp(
2525
innerRegex.source +
2626
")" +
2727
")" +
28-
"\\s*"
28+
"\\s*",
2929
);
3030
/* eslint-enable prefer-template */
3131

@@ -145,7 +145,7 @@ async function fetchFromFilesystem(loaderContext, sourceURL) {
145145
});
146146
} catch (error) {
147147
throw new Error(
148-
`Failed to parse source map from '${sourceURL}' file: ${error}`
148+
`Failed to parse source map from '${sourceURL}' file: ${error}`,
149149
);
150150
}
151151

@@ -155,15 +155,15 @@ async function fetchFromFilesystem(loaderContext, sourceURL) {
155155
async function fetchPathsFromFilesystem(
156156
loaderContext,
157157
possibleRequests,
158-
errorsAccumulator = ""
158+
errorsAccumulator = "",
159159
) {
160160
let result;
161161

162162
try {
163163
result = await fetchFromFilesystem(
164164
loaderContext,
165165
possibleRequests[0],
166-
errorsAccumulator
166+
errorsAccumulator,
167167
);
168168
} catch (error) {
169169
// eslint-disable-next-line no-param-reassign
@@ -180,7 +180,7 @@ async function fetchPathsFromFilesystem(
180180
return fetchPathsFromFilesystem(
181181
loaderContext,
182182
tailPossibleRequests,
183-
errorsAccumulator
183+
errorsAccumulator,
184184
);
185185
}
186186

@@ -196,7 +196,7 @@ async function fetchFromURL(
196196
context,
197197
url,
198198
sourceRoot,
199-
skipReading = false
199+
skipReading = false,
200200
) {
201201
// 1. It's an absolute url and it is not `windows` path like `C:\dir\file`
202202
if (isURL(url)) {
@@ -221,21 +221,21 @@ async function fetchFromURL(
221221
const sourceURL = path.normalize(pathFromURL);
222222
const { data: sourceContent } = await fetchFromFilesystem(
223223
loaderContext,
224-
sourceURL
224+
sourceURL,
225225
);
226226

227227
return { sourceURL, sourceContent };
228228
}
229229

230230
throw new Error(
231-
`Failed to parse source map: '${url}' URL is not supported`
231+
`Failed to parse source map: '${url}' URL is not supported`,
232232
);
233233
}
234234

235235
// 2. It's a scheme-relative
236236
if (/^\/\//.test(url)) {
237237
throw new Error(
238-
`Failed to parse source map: '${url}' URL is not supported`
238+
`Failed to parse source map: '${url}' URL is not supported`,
239239
);
240240
}
241241

@@ -250,13 +250,13 @@ async function fetchFromURL(
250250

251251
if (url.startsWith("/")) {
252252
possibleRequests.push(
253-
getAbsolutePath(context, sourceURL.slice(1), sourceRoot)
253+
getAbsolutePath(context, sourceURL.slice(1), sourceRoot),
254254
);
255255
}
256256

257257
const result = await fetchPathsFromFilesystem(
258258
loaderContext,
259-
possibleRequests
259+
possibleRequests,
260260
);
261261

262262
sourceURL = result.path;

test/helpers/execute.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default (code) => {
88
const module = new Module(resource, parentModule);
99
// eslint-disable-next-line no-underscore-dangle
1010
module.paths = Module._nodeModulePaths(
11-
path.resolve(__dirname, "../fixtures")
11+
path.resolve(__dirname, "../fixtures"),
1212
);
1313
module.filename = resource;
1414

test/helpers/getCodeFromBundle.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function getCodeFromBundle(stats, compiler, asset) {
2222
`${code};\nmodule.exports = sourceMapLoaderExport;`,
2323
{
2424
module: {},
25-
}
25+
},
2626
);
2727

2828
// eslint-disable-next-line no-underscore-dangle

test/helpers/getCompiler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default (
77
fixture,
88
loaderOptions = {},
99
config = {},
10-
skipTestLoader = false
10+
skipTestLoader = false,
1111
) => {
1212
const loaders = [
1313
{

test/loader.test.js

+19-16
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ describe("source-map-loader", () => {
172172
// Create the entryPointFile file
173173
const entryFileContent = `// Some content \r\n // # sourceMappingURL=file://${sourceMapPath.replace(
174174
/\\/g,
175-
"/"
175+
"/",
176176
)}`;
177177
fs.writeFileSync(entryFileAbsolutePath, entryFileContent);
178178

@@ -267,13 +267,16 @@ describe("source-map-loader", () => {
267267
expect(codeFromBundle.map).toBeUndefined();
268268
expect(codeFromBundle.code).toMatchSnapshot("code");
269269

270-
if (process.version.startsWith("v20")) {
270+
if (
271+
process.version.startsWith("v20") ||
272+
process.version.startsWith("v21")
273+
) {
271274
expect(getWarnings(stats)[0]).toContain(
272-
`SyntaxError: Unexpected non-whitespace character after JSON at position 102`
275+
`SyntaxError: Unexpected non-whitespace character after JSON at position 102`,
273276
);
274277
} else {
275278
expect(getWarnings(stats)[0]).toContain(
276-
`SyntaxError: Unexpected string in JSON at position 102`
279+
`SyntaxError: Unexpected string in JSON at position 102`,
277280
);
278281
}
279282
expect(getErrors(stats)).toMatchSnapshot("errors");
@@ -332,7 +335,7 @@ describe("source-map-loader", () => {
332335
const rootRelativeSourcePath = path.join(sourceRoot, sourceFilename);
333336
const sourceMapPath = path.join(
334337
sourceRoot,
335-
"absolute-sourceRoot-source-map.map"
338+
"absolute-sourceRoot-source-map.map",
336339
);
337340

338341
// Create the sourcemap file
@@ -368,12 +371,12 @@ describe("source-map-loader", () => {
368371
__dirname,
369372
"fixtures",
370373
"data",
371-
sourceFilename
374+
sourceFilename,
372375
);
373376
const sourceMapPath = path.join(
374377
__dirname,
375378
"fixtures",
376-
"relative-sourceRoot-source-map.map"
379+
"relative-sourceRoot-source-map.map",
377380
);
378381

379382
const testId = "relative-sourceRoot-source-map.js";
@@ -398,7 +401,7 @@ describe("source-map-loader", () => {
398401
const currentDirPath = path.join(
399402
__dirname,
400403
"fixtures",
401-
"indexed-sourcemap"
404+
"indexed-sourcemap",
402405
);
403406

404407
const testId = path.join(currentDirPath, "file.js");
@@ -426,7 +429,7 @@ describe("source-map-loader", () => {
426429
const currentDirPath = path.join(
427430
__dirname,
428431
"fixtures",
429-
"indexed-sourcemap"
432+
"indexed-sourcemap",
430433
);
431434

432435
const testId = path.join(currentDirPath, "file2.js");
@@ -454,7 +457,7 @@ describe("source-map-loader", () => {
454457
const currentDirPath = path.join(
455458
__dirname,
456459
"fixtures",
457-
"indexed-sourcemap"
460+
"indexed-sourcemap",
458461
);
459462

460463
const testId = path.join(currentDirPath, "file.js");
@@ -472,8 +475,8 @@ describe("source-map-loader", () => {
472475
path.normalize(
473476
source
474477
.replace(/webpack:\/\/sourceMapLoaderExport\//, "")
475-
.replace("..", "")
476-
)
478+
.replace("..", ""),
479+
),
477480
);
478481

479482
expect(new Set(normalizedSources)).toEqual(new Set(dependencies));
@@ -497,7 +500,7 @@ describe("source-map-loader", () => {
497500
const entryFileAbsolutePath = path.join(sourceRoot, javaScriptFilename);
498501
const sourceMapPath = path.join(
499502
sourceRoot,
500-
"map-without-sourceroot.js.map"
503+
"map-without-sourceroot.js.map",
501504
);
502505

503506
// Create the sourcemap file
@@ -653,7 +656,7 @@ describe("source-map-loader", () => {
653656
const codeFromBundle = getCodeFromBundle(stats, compiler);
654657

655658
expect(
656-
stats.toString({ warningsFilter: /Failed to parse source map/ })
659+
stats.toString({ warningsFilter: /Failed to parse source map/ }),
657660
).not.toContain("Failed to parse source map");
658661
expect(codeFromBundle.map).toBeUndefined();
659662
expect(codeFromBundle.code).toMatchSnapshot("code");
@@ -667,7 +670,7 @@ describe("source-map-loader", () => {
667670
const sourceFilename = "server-relative-url-path.js";
668671
const sourceMapPath = path.join(
669672
sourceRoot,
670-
"server-relative-url-path.js.map"
673+
"server-relative-url-path.js.map",
671674
);
672675

673676
// Create the sourcemap file
@@ -715,7 +718,7 @@ describe("source-map-loader", () => {
715718
path.resolve(
716719
__dirname,
717720
"fixtures",
718-
"data/relative-sourceRoot-source-map.txt"
721+
"data/relative-sourceRoot-source-map.txt",
719722
),
720723
];
721724
const notInDependencies = ["", "data:invalid;A;a", "./data/not-found.txt"];

0 commit comments

Comments
 (0)