Skip to content

Commit

Permalink
removed support for custom file extensions
Browse files Browse the repository at this point in the history
Co-authored-by: FND <fnd@localhost.localdomain>
  • Loading branch information
moonglum and FND committed Jan 16, 2023
1 parent 58a1eb1 commit f534d52
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 39 deletions.
7 changes: 1 addition & 6 deletions lib/bundle/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = function generateTranspiler({ esnext, jsx, exclude }, { browser
babelHelpers: "bundled"
};
let plugins = [];
let extensions = [];

if(exclude) {
settings.exclude = exclude.map(pkg => {
Expand All @@ -32,7 +31,6 @@ module.exports = function generateTranspiler({ esnext, jsx, exclude }, { browser
}

if(jsx) {
extensions.push(".jsx");
let { pragma, pragmaFrag } = jsx;
plugins.push(["@babel/plugin-transform-react-jsx",
{ pragma, pragmaFrag }]);
Expand All @@ -44,8 +42,5 @@ module.exports = function generateTranspiler({ esnext, jsx, exclude }, { browser

let babel = loadExtension("@rollup/plugin-babel",
"failed to activate ESNext transpiler", "faucet-pipeline-esnext");
return {
plugin: babel.default(settings),
extensions
};
return babel.default(settings);
};
17 changes: 5 additions & 12 deletions lib/bundle/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ let NAMELESS_MODULES = new Set(["es", "amd", "cjs"]); // NB: Rollup identifiers
module.exports = generateConfig;

// generates Rollup configuration
// * `extensions` is a list of additional file extensions for loading modules
// (e.g. `[".jsx"]`)
// * `externals` determines which modules/packages to exclude from the bundle
// (e.g. `{ jquery: "jQuery" }` - the key refers to the respective
// module/package name, the value refers to a corresponding global variable)
Expand All @@ -47,19 +45,20 @@ 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({ extensions = [], // eslint-disable-next-line indent
externals, format, exports, // eslint-disable-next-line indent
function generateConfig({ externals, format, exports, // eslint-disable-next-line indent
esnext, jsx, typescript, // eslint-disable-next-line indent
sourcemaps, compact }, { browsers }) {
let cfg = { sourcemap: sourcemaps };
let plugins = [];
let extensions = [".js"];

if(esnext || jsx) {
let transpiler = Object.assign({}, esnext, jsx);
if(esnext) {
transpiler.esnext = true;
}
if(jsx) {
extensions.push(".jsx");
// just to be safe, discard JSX-specifics on parent object
delete transpiler.pragma;
delete transpiler.fragment;
Expand All @@ -76,8 +75,7 @@ function generateConfig({ extensions = [], // eslint-disable-next-line indent
console.error("transpiling JavaScript for", browsers.join(", "));
}

let { plugin, extensions: ext } = generateTranspiler(transpiler, { browsers });
extensions = ext.concat(extensions);
let plugin = generateTranspiler(transpiler, { browsers });
plugins.push(plugin);
}
if(typescript) {
Expand All @@ -88,13 +86,8 @@ function generateConfig({ extensions = [], // eslint-disable-next-line indent
plugins.push(typescript === true ? ts() : ts(typescript));
}

let resolve = {};
if(extensions.length) {
resolve.extensions = [".js"].concat(extensions);
}

plugins = plugins.concat([
nodeResolve(resolve),
nodeResolve({ extensions }),
commonjs({ include: "node_modules/**" })
]);
if(compact) {
Expand Down
21 changes: 0 additions & 21 deletions test/unit/test_bundling.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,27 +118,6 @@ console.log("[\\u2026] ".concat(MYLIB)); // eslint-disable-line no-console
});
});

it("should support custom file extensions", () => {
let config = [{
source: "./src/index.coffee",
target: "./dist/bundle.js",
extensions: [".coffee"]
}];
let assetManager = new MockAssetManager(FIXTURES_DIR);

return faucetJS(config, assetManager, DEFAULT_OPTIONS)().
then(_ => {
assetManager.assertWrites([{
filepath: path.resolve(FIXTURES_DIR, "./dist/bundle.js"),
content: makeBundle(`
var helper = { foo: "lorem", bar: "ipsum" };
console.log(\`[…] $\{helper}\`); // eslint-disable-line no-console
`)
}]);
});
});

it("should support customizing bundle's API", () => {
let config = [{
source: "./src/lib.js",
Expand Down

0 comments on commit f534d52

Please sign in to comment.