diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 862639a..e1b6302 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -8,10 +8,11 @@ jobs: matrix: node-version: - 18.x - - 21.x + - 22.x + - latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm install-test diff --git a/CHANGELOG.md b/CHANGELOG.md index 1368021..012f661 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,20 @@ faucet-pipeline-js version history ================================== +v3.0.2 +------ + +_2025-02-01_ + +notable changes for end users: + +* dropped support for obsolete Node versions; now requires Node v18 or later +* dropped support for undocumented ESM aliases +* reduced number of dependencies + +no significant changes for developers + + v3.0.1 ------ diff --git a/lib/bundle/babel.js b/lib/bundle/babel.js index 6de07ed..9e3fe2c 100644 --- a/lib/bundle/babel.js +++ b/lib/bundle/babel.js @@ -2,7 +2,8 @@ let { loadExtension } = require("faucet-pipeline-core/lib/util"); -module.exports = function generateTranspiler({ esnext, jsx, exclude }, { browsers }) { +module.exports = async function generateTranspiler({ esnext, jsx, exclude }, + { browsers }) { // eslint-disable-line indent let settings = { babelHelpers: "bundled" }; @@ -40,7 +41,7 @@ module.exports = function generateTranspiler({ esnext, jsx, exclude }, { browser settings.plugins = plugins; } - let babel = loadExtension("@rollup/plugin-babel", + let babel = await loadExtension("@rollup/plugin-babel", "failed to activate ESNext transpiler", "faucet-pipeline-esnext"); return babel.default(settings); }; diff --git a/lib/bundle/config.js b/lib/bundle/config.js index 7e020fa..388be44 100644 --- a/lib/bundle/config.js +++ b/lib/bundle/config.js @@ -8,15 +8,13 @@ let { nodeResolve } = require("@rollup/plugin-node-resolve"); let MODULE_FORMATS = { // maps faucet identifiers to Rollup identifiers esm: true, - es: "esm", // alias - es6: "esm", // alias umd: true, amd: true, commonjs: "cjs", cjs: false, // deprecated in favor of `commonjs` iife: true }; -let NAMELESS_MODULES = new Set(["es", "amd", "cjs"]); // NB: Rollup identifiers +let NAMELESS_MODULES = new Set(["esm", "amd", "cjs"]); // NB: Rollup identifiers module.exports = generateConfig; @@ -45,9 +43,9 @@ module.exports = generateConfig; // * `sourcemaps`, if truthy, activates inline source-map generation // * `compact`, if truthy, compresses the bundle's code - see `determineCompacting` // for compression levels, determined by the respective value -function generateConfig({ externals, format, exports, // eslint-disable-next-line indent - esnext, jsx, typescript, // eslint-disable-next-line indent - sourcemaps, compact }, { browsers }) { +async function generateConfig({ externals, format, + exports, esnext, jsx, typescript, // eslint-disable-line indent + sourcemaps, compact }, { browsers }) { // eslint-disable-line indent let cfg = { sourcemap: sourcemaps }; let plugins = []; let extensions = [".js"]; @@ -75,11 +73,11 @@ function generateConfig({ externals, format, exports, // eslint-disable-next-lin console.error("transpiling JavaScript for", browsers.join(", ")); } - let plugin = generateTranspiler(transpiler, { browsers }); + let plugin = await generateTranspiler(transpiler, { browsers }); plugins.push(plugin); } if(typescript) { - let ts = loadExtension("@rollup/plugin-typescript", + let ts = await loadExtension("@rollup/plugin-typescript", "failed to activate TypeScript", "faucet-pipeline-typescript"); extensions.push(".ts"); // TODO: provide defaults and abstractions for low-level options? @@ -92,7 +90,7 @@ function generateConfig({ externals, format, exports, // eslint-disable-next-lin ]); if(compact) { cfg.compact = true; - plugins = plugins.concat(determineCompacting(compact)); + plugins = plugins.concat(await determineCompacting(compact)); } cfg.plugins = plugins; @@ -138,7 +136,7 @@ function determineModuleFormat(format = "esm") { } } -function determineCompacting(type = true) { +async function determineCompacting(type = true) { switch(type) { case true: // default case "compact": @@ -153,7 +151,7 @@ function determineCompacting(type = true) { abort(`unknown compacting option ${type}`); } - let terser = loadExtension("@rollup/plugin-terser", + let terser = await loadExtension("@rollup/plugin-terser", "failed to activate minification", "faucet-pipeline-jsmin"); return terser(options); } diff --git a/lib/bundle/index.js b/lib/bundle/index.js index 10462f0..5b693c3 100644 --- a/lib/bundle/index.js +++ b/lib/bundle/index.js @@ -33,7 +33,8 @@ module.exports = class Bundle { return false; } - return generateBundle(this.entryPoint, this._config, this._cache). + return this._config. + then(config => generateBundle(this.entryPoint, config, this._cache)). then(({ code, modules, cache }) => { this._modules = modules; this._cache = cache; diff --git a/package.json b/package.json index b897308..e34fc51 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "faucet-pipeline-js", - "version": "3.0.1", + "version": "3.0.2", "description": "JavaScript module bundling for faucet-pipeline", "author": "FND", "contributors": [ @@ -17,19 +17,19 @@ }, "main": "lib/index.js", "scripts": { - "test": "npm-run-all lint --parallel test:unit test:cli", + "test": "npm run lint && npm run test:unit && npm run test:cli", "test:cli": "./test/cli/run", - "test:unit": "mocha test/unit/test_*.js", - "lint": "eslint --cache --ext .js --ext .jsx lib bin/validate-dependencies test/unit samples pkg && echo ✓" + "test:unit": "node --test ./test/unit/test_*.js", + "lint": "eslint --cache --ext .js --ext .jsx ./lib ./bin/validate-dependencies ./test/unit ./samples ./pkg && echo ✓" }, "engines": { - "node": ">=14" + "node": ">=18" }, "dependencies": { - "@rollup/plugin-commonjs": "~25.0.7", - "@rollup/plugin-node-resolve": "~15.2.3", - "faucet-pipeline-core": "^2.0.0", - "rollup": "^4.3.0", + "@rollup/plugin-commonjs": "~26.0.3", + "@rollup/plugin-node-resolve": "~16.0.0", + "faucet-pipeline-core": "^2.0.0 || ^3.0.0", + "rollup": "^4.34.0", "rollup-plugin-cleanup": "~3.2.1" }, "devDependencies": { @@ -39,8 +39,6 @@ "faucet-pipeline-jsx": "file:pkg/faucet-pipeline-jsx", "faucet-pipeline-typescript": "file:pkg/faucet-pipeline-typescript", "json-diff": "^1.0.6", - "mocha": "^10.2.0", - "npm-run-all": "^4.1.5", "release-util-fnd": "^3.0.0" } } diff --git a/pkg/faucet-pipeline-esnext/package.json b/pkg/faucet-pipeline-esnext/package.json index ce32bb8..16a0a99 100644 --- a/pkg/faucet-pipeline-esnext/package.json +++ b/pkg/faucet-pipeline-esnext/package.json @@ -1,6 +1,6 @@ { "name": "faucet-pipeline-esnext", - "version": "3.0.1", + "version": "3.0.2", "description": "ES6 and beyond for faucet-pipeline", "author": "FND", "license": "Apache-2.0", @@ -13,9 +13,9 @@ "url": "https://github.com/faucet-pipeline/faucet-pipeline-js/issues" }, "dependencies": { - "@babel/core": "~7.23.3", - "@babel/preset-env": "~7.23.3", + "@babel/core": "~7.26.7", + "@babel/preset-env": "~7.26.7", "@rollup/plugin-babel": "~6.0.4", - "faucet-pipeline-js": "3.0.1" + "faucet-pipeline-js": "3.0.2" } } diff --git a/pkg/faucet-pipeline-jsmin/package.json b/pkg/faucet-pipeline-jsmin/package.json index 94faee0..df301ee 100644 --- a/pkg/faucet-pipeline-jsmin/package.json +++ b/pkg/faucet-pipeline-jsmin/package.json @@ -1,6 +1,6 @@ { "name": "faucet-pipeline-jsmin", - "version": "3.0.1", + "version": "3.0.2", "description": "JavaScript minification for faucet-pipeline", "author": "FND", "license": "Apache-2.0", diff --git a/pkg/faucet-pipeline-jsx/package.json b/pkg/faucet-pipeline-jsx/package.json index db5b773..ce4e9ba 100644 --- a/pkg/faucet-pipeline-jsx/package.json +++ b/pkg/faucet-pipeline-jsx/package.json @@ -1,6 +1,6 @@ { "name": "faucet-pipeline-jsx", - "version": "3.0.1", + "version": "3.0.2", "description": "JSX for faucet-pipeline", "author": "FND", "license": "Apache-2.0", @@ -13,7 +13,7 @@ "url": "https://github.com/faucet-pipeline/faucet-pipeline-js/issues" }, "dependencies": { - "@babel/plugin-transform-react-jsx": "~7.22.15", - "faucet-pipeline-esnext": "3.0.1" + "@babel/plugin-transform-react-jsx": "~7.25.9", + "faucet-pipeline-esnext": "3.0.2" } } diff --git a/pkg/faucet-pipeline-typescript/package.json b/pkg/faucet-pipeline-typescript/package.json index 143023c..5e5f645 100644 --- a/pkg/faucet-pipeline-typescript/package.json +++ b/pkg/faucet-pipeline-typescript/package.json @@ -1,6 +1,6 @@ { "name": "faucet-pipeline-typescript", - "version": "3.0.1", + "version": "3.0.2", "description": "TypeScript for faucet-pipeline", "author": "FND", "contributors": [ @@ -16,9 +16,9 @@ "url": "https://github.com/faucet-pipeline/faucet-pipeline-js/issues" }, "dependencies": { - "@rollup/plugin-typescript": "~11.1.5", - "faucet-pipeline-js": "3.0.1", - "tslib": "~2.6.2", - "typescript": "~5.2.2" + "@rollup/plugin-typescript": "~12.1.2", + "faucet-pipeline-js": "3.0.2", + "tslib": "~2.8.1", + "typescript": "~5.7.3" } } diff --git a/test/cli/test_browserslist/expected_legacy.js b/test/cli/test_browserslist/expected_legacy.js index 5dc92da..21fc140 100644 --- a/test/cli/test_browserslist/expected_legacy.js +++ b/test/cli/test_browserslist/expected_legacy.js @@ -1,38 +1,10 @@ -function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } +function _classCallCheck(a, n) { + if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } -function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); - } -} -function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - Object.defineProperty(Constructor, "prototype", { +function _createClass(e, r, t) { + return Object.defineProperty(e, "prototype", { writable: false - }); - return Constructor; -} -function _toPrimitive(input, hint) { - if (typeof input !== "object" || input === null) return input; - var prim = input[Symbol.toPrimitive]; - if (prim !== undefined) { - var res = prim.call(input, hint || "default"); - if (typeof res !== "object") return res; - throw new TypeError("@@toPrimitive must return a primitive value."); - } - return (hint === "string" ? String : Number)(input); -} -function _toPropertyKey(arg) { - var key = _toPrimitive(arg, "string"); - return typeof key === "symbol" ? key : String(key); + }), e; } var Util = /*#__PURE__*/_createClass(function Util() { diff --git a/test/cli/test_jsx/expected.js b/test/cli/test_jsx/expected.js index 04a203b..ad5acc0 100644 --- a/test/cli/test_jsx/expected.js +++ b/test/cli/test_jsx/expected.js @@ -1,38 +1,10 @@ -function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } +function _classCallCheck(a, n) { + if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } -function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); - } -} -function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - Object.defineProperty(Constructor, "prototype", { +function _createClass(e, r, t) { + return Object.defineProperty(e, "prototype", { writable: false - }); - return Constructor; -} -function _toPrimitive(input, hint) { - if (typeof input !== "object" || input === null) return input; - var prim = input[Symbol.toPrimitive]; - if (prim !== undefined) { - var res = prim.call(input, hint || "default"); - if (typeof res !== "object") return res; - throw new TypeError("@@toPrimitive must return a primitive value."); - } - return (hint === "string" ? String : Number)(input); -} -function _toPropertyKey(arg) { - var key = _toPrimitive(arg, "string"); - return typeof key === "symbol" ? key : String(key); + }), e; } var MyComponent = /*#__PURE__*/_createClass(function MyComponent() { diff --git a/test/cli/test_sourcemap/expected.js.map b/test/cli/test_sourcemap/expected.js.map index 6248ddc..2299c3b 100644 --- a/test/cli/test_sourcemap/expected.js.map +++ b/test/cli/test_sourcemap/expected.js.map @@ -1 +1 @@ -{"version":3,"sourcesContent":["export default class Util {}\n\nexport const FOO = \"lorem ipsum\";\nexport const BAR = \"dolor sit amet\";\n","import Util, { FOO, BAR } from \"./util\";\n\nconsole.log(`~~ ${Util} ~~ ${FOO} ~~ ${BAR} ~~`);\n"],"names":[],"mappings":"AAAe,MAAM,IAAI,CAAC,EAAE;AAC5B;AACO,MAAM,GAAG,GAAG,aAAa,CAAC;AAC1B,MAAM,GAAG,GAAG,gBAAgB;;ACDnC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC"} +{"version":3,"sourcesContent":["export default class Util {}\n\nexport const FOO = \"lorem ipsum\";\nexport const BAR = \"dolor sit amet\";\n","import Util, { FOO, BAR } from \"./util\";\n\nconsole.log(`~~ ${Util} ~~ ${FOO} ~~ ${BAR} ~~`);\n"],"names":[],"mappings":"AAAe,MAAM,IAAI,CAAC;;AAEnB,MAAM,GAAG,GAAG,aAAa;AACzB,MAAM,GAAG,GAAG,gBAAgB;;ACDnC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC"} diff --git a/test/cli/test_transpilation/expected.js b/test/cli/test_transpilation/expected.js index 5dc92da..21fc140 100644 --- a/test/cli/test_transpilation/expected.js +++ b/test/cli/test_transpilation/expected.js @@ -1,38 +1,10 @@ -function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } +function _classCallCheck(a, n) { + if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } -function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); - } -} -function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - Object.defineProperty(Constructor, "prototype", { +function _createClass(e, r, t) { + return Object.defineProperty(e, "prototype", { writable: false - }); - return Constructor; -} -function _toPrimitive(input, hint) { - if (typeof input !== "object" || input === null) return input; - var prim = input[Symbol.toPrimitive]; - if (prim !== undefined) { - var res = prim.call(input, hint || "default"); - if (typeof res !== "object") return res; - throw new TypeError("@@toPrimitive must return a primitive value."); - } - return (hint === "string" ? String : Number)(input); -} -function _toPropertyKey(arg) { - var key = _toPrimitive(arg, "string"); - return typeof key === "symbol" ? key : String(key); + }), e; } var Util = /*#__PURE__*/_createClass(function Util() { diff --git a/test/unit/test_bundling.js b/test/unit/test_bundling.js index 7c10934..1990a4e 100644 --- a/test/unit/test_bundling.js +++ b/test/unit/test_bundling.js @@ -1,10 +1,9 @@ -/* global describe, it, beforeEach, afterEach */ "use strict"; - let { MockAssetManager, makeBundle, FIXTURES_DIR } = require("./util"); let faucetJS = require("../../lib").plugin; -let path = require("path"); -let assert = require("assert"); +let { describe, it, beforeEach, afterEach } = require("node:test"); +let path = require("node:path"); +let assert = require("node:assert"); let DEFAULT_OPTIONS = { browsers: {}