Skip to content
Open

3.1.0 #236

Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/bundle/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
};
Expand Down Expand Up @@ -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);
};
27 changes: 18 additions & 9 deletions lib/bundle/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let MODULE_FORMATS = { // maps faucet identifiers to Rollup identifiers
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;

Expand Down Expand Up @@ -45,19 +45,21 @@ 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"];

if(esnext || jsx) {
let transpiler = Object.assign({}, esnext, jsx);
if(esnext) {
console.error("WARNING: `esnext` option is deprecated");
transpiler.esnext = true;
}
if(jsx) {
console.error("WARNING: `jsx` option is deprecated");
extensions.push(".jsx");
// just to be safe, discard JSX-specifics on parent object
delete transpiler.pragma;
Expand All @@ -75,11 +77,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?
Expand All @@ -92,12 +94,17 @@ 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;

if(format) {
console.error("WARNING: `format` option is deprecated; " +
"faucet-pipeline-js will always compile to ESM in the future");
}
cfg.format = determineModuleFormat(format);
if(exports) {
console.error("WARNING: `exports` option is deprecated");
if(NAMELESS_MODULES.has(format)) {
console.error(`WARNING: ${repr(format, false)} bundles ignore ` +
`${repr("exports", false)} configuration`);
Expand Down Expand Up @@ -138,7 +145,7 @@ function determineModuleFormat(format = "esm") {
}
}

function determineCompacting(type = true) {
async function determineCompacting(type = true) {
switch(type) {
case true: // default
case "compact":
Expand All @@ -147,13 +154,15 @@ function determineCompacting(type = true) {
var options = { compress: false, mangle: false }; // eslint-disable-line no-var
break;
case "mangle":
console.error("WARNING: `compact` option `mangle` is deprecated; " +
"use `minify` instead");
options = { compress: false, mangle: true };
break;
default:
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);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/bundle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
},
"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": ">=22"
},
"dependencies": {
"@rollup/plugin-commonjs": "~29.0.1",
"@rollup/plugin-node-resolve": "~16.0.3",
"faucet-pipeline-core": "^2.0.0",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would need to double check if with this version, faucet-pipeline-js is compatible with all planned changs for the 3.x branch. Additionally, I think 3.0.0 is the yanked version, so we are probably talking about 3.1.0 at this point? 🤔

https://github.com/faucet-pipeline/faucet-pipeline-core/pulls

"faucet-pipeline-core": "^2.0.0 || ^3.0.0",
"rollup": "^4.59.0",
"rollup-plugin-cleanup": "~3.2.1"
},
Expand All @@ -37,8 +37,6 @@
"faucet-pipeline-jsx": "file:pkg/faucet-pipeline-jsx",
"faucet-pipeline-typescript": "file:pkg/faucet-pipeline-typescript",
"json-diff": "^1.0.6",
"mocha": "^11.7.5",
"npm-run-all": "^4.1.5",
"release-util-fnd": "^3.0.0"
}
}
7 changes: 3 additions & 4 deletions test/unit/test_bundling.js
Original file line number Diff line number Diff line change
@@ -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: {}
Expand Down