Skip to content

Commit

Permalink
chore!: minimum supported Node.js version is 18.12.0 (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored Jan 15, 2024
1 parent 59a7497 commit ed762dc
Show file tree
Hide file tree
Showing 11 changed files with 7,757 additions and 16,699 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [18.x, 20.x, 21.x]
webpack-version: [latest]

runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ module.exports = {
executableFile: path.resolve(
__dirname,
"fixtures",
"executableFile.js"
"executableFile.js",
),
},
},
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = (api) => {
"@babel/preset-env",
{
targets: {
node: "14.15.0",
node: "18.12.0",
},
},
],
Expand Down
24,278 changes: 7,668 additions & 16,610 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"main": "dist/cjs.js",
"engines": {
"node": ">= 14.15.0"
"node": ">= 18.12.0"
},
"scripts": {
"start": "npm run build -- -w",
Expand All @@ -24,7 +24,7 @@
"security": "npm audit --production",
"lint:prettier": "prettier --list-different .",
"lint:js": "eslint --cache .",
"lint:spelling": "cspell \"**/*.*\"",
"lint:spelling": "cspell --no-must-find-files --cache --quiet \"**/*.*\"",
"lint": "npm-run-all -l -p \"lint:**\"",
"fix:js": "npm run lint:js -- --fix",
"fix:prettier": "npm run lint:prettier -- --write",
Expand All @@ -46,26 +46,26 @@
"devDependencies": {
"@babel/cli": "^7.23.4",
"@babel/core": "^7.23.7",
"@babel/preset-env": "^7.23.7",
"@commitlint/cli": "^17.7.2",
"@commitlint/config-conventional": "^17.7.0",
"@babel/preset-env": "^7.23.8",
"@commitlint/cli": "^18.4.4",
"@commitlint/config-conventional": "^18.4.4",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"cross-env": "^7.0.3",
"cspell": "^6.31.2",
"del": "^6.1.1",
"del-cli": "^4.0.1",
"cspell": "^8.3.2",
"del": "^7.1.0",
"del-cli": "^5.1.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.9.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"figlet": "^1.7.0",
"husky": "^8.0.3",
"jest": "^29.7.0",
"lint-staged": "^13.2.3",
"memfs": "^3.5.1",
"lint-staged": "^15.2.0",
"memfs": "^4.6.0",
"modernizr": "^3.13.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.8",
"standard-version": "^9.3.2",
"prettier": "^3.2.2",
"standard-version": "^9.5.0",
"webpack": "^5.89.0"
},
"keywords": [
Expand Down
20 changes: 10 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ function processResult(loaderContext, result) {
if (!result || typeof result !== "object" || "code" in result === false) {
loaderContext.callback(
new Error(
`The returned result of module "${loaderContext.resource}" is not an object with a "code" property`
)
`The returned result of module "${loaderContext.resource}" is not an object with a "code" property`,
),
);

return;
Expand All @@ -36,23 +36,23 @@ function processResult(loaderContext, result) {
) {
loaderContext.callback(
new Error(
`The returned code of module "${loaderContext.resource}" is neither a string nor an instance of Buffer`
)
`The returned code of module "${loaderContext.resource}" is neither a string nor an instance of Buffer`,
),
);

return;
}

(result.dependencies || []).forEach((dep) =>
loaderContext.addDependency(dep)
loaderContext.addDependency(dep),
);

(result.contextDependencies || []).forEach((dep) =>
loaderContext.addContextDependency(dep)
loaderContext.addContextDependency(dep),
);

(result.buildDependencies || []).forEach((dep) =>
loaderContext.addBuildDependency(dep)
loaderContext.addBuildDependency(dep),
);

// Defaults to false which is a good default here because we assume that
Expand All @@ -63,7 +63,7 @@ function processResult(loaderContext, result) {
null,
result.code,
result.sourceMap || null,
result.ast || null
result.ast || null,
);
}

Expand Down Expand Up @@ -121,8 +121,8 @@ export default async function loader(content) {
if (typeof func !== "function") {
callback(
new Error(
`Module "${this.resource}" does not export a function as default`
)
`Module "${this.resource}" does not export a function as default`,
),
);
return;
}
Expand Down
22 changes: 11 additions & 11 deletions test/executableFile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("executableFile option", () => {
executableFile: path.resolve(
__dirname,
"fixtures",
"executableFile.js"
"executableFile.js",
),
},
},
Expand All @@ -34,15 +34,15 @@ describe("executableFile option", () => {
},
],
},
}
},
);
const stats = await compile(compiler);

expect(readAsset("val-loader.js", compiler, stats)).toMatchSnapshot(
"result"
"result",
);
expect(normalizeErrors(stats.compilation.warnings)).toMatchSnapshot(
"warnings"
"warnings",
);
expect(normalizeErrors(stats.compilation.errors)).toMatchSnapshot("errors");
});
Expand All @@ -67,7 +67,7 @@ describe("executableFile option", () => {
executableFile: path.resolve(
__dirname,
"fixtures",
"executableFileES.mjs"
"executableFileES.mjs",
),
},
},
Expand All @@ -79,15 +79,15 @@ describe("executableFile option", () => {
},
],
},
}
},
);
const stats = await compile(compiler);

expect(readAsset("val-loader.js", compiler, stats)).toMatchSnapshot(
"result"
"result",
);
expect(normalizeErrors(stats.compilation.warnings)).toMatchSnapshot(
"warnings"
"warnings",
);
expect(normalizeErrors(stats.compilation.errors)).toMatchSnapshot("errors");
});
Expand All @@ -111,7 +111,7 @@ describe("executableFile option", () => {
executableFile: path.resolve(
__dirname,
"fixtures",
"error-require.js"
"error-require.js",
),
},
},
Expand All @@ -123,12 +123,12 @@ describe("executableFile option", () => {
},
],
},
}
},
);
const stats = await compile(compiler);

expect(normalizeErrors(stats.compilation.warnings)).toMatchSnapshot(
"warnings"
"warnings",
);
expect(normalizeErrors(stats.compilation.errors)).toMatchSnapshot("errors");
});
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ export default (code) => {
const module = new Module(resource, parentModule);
// eslint-disable-next-line no-underscore-dangle
module.paths = Module._nodeModulePaths(
path.resolve(__dirname, "../fixtures")
path.resolve(__dirname, "../fixtures"),
);
module.filename = resource;

// eslint-disable-next-line no-underscore-dangle
module._compile(
`let __export__;${code};module.exports = __export__;`,
resource
resource,
);

return module.exports;
Expand Down
8 changes: 4 additions & 4 deletions test/helpers/helperLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ function rel(p) {

export default function helperLoader(content, map, meta) {
const dependencies = this.getDependencies().map((dependency) =>
rel(dependency).replace(/\\/g, "/")
rel(dependency).replace(/\\/g, "/"),
);
const contextDependencies = this.getContextDependencies().map((dependency) =>
rel(dependency).replace(/\\/g, "/")
rel(dependency).replace(/\\/g, "/"),
);

const buildDependencies = Array.from(
this._module.buildInfo.buildDependencies || []
this._module.buildInfo.buildDependencies || [],
).map((dependency) => rel(dependency).replace(/\\/g, "/"));
const json = JSON.stringify(
{
Expand All @@ -25,7 +25,7 @@ export default function helperLoader(content, map, meta) {
buildDependencies,
},
null,
" "
" ",
)
.replace(/\u2028/g, "\\u2028")
.replace(/\u2029/g, "\\u2029");
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/normalizeErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ function removeCWD(str) {
.replace(new RegExp(cwd, "g"), "")
.replace(
/Cannot read property 'get' of undefined/,
"Cannot read properties of undefined (reading 'get')"
"Cannot read properties of undefined (reading 'get')",
);
}

export default (errors) =>
errors.map((error) =>
removeCWD(error.toString().split("\n").slice(0, 2).join("\n"))
removeCWD(error.toString().split("\n").slice(0, 2).join("\n")),
);
Loading

0 comments on commit ed762dc

Please sign in to comment.