diff --git a/scripts/bundle-esm.js b/scripts/bundle-esm.js index 9291f6b855..adfb9eecbc 100644 --- a/scripts/bundle-esm.js +++ b/scripts/bundle-esm.js @@ -1,14 +1,15 @@ 'use strict'; -/* eslint-disable no-console */ -/* eslint-disable guard-for-in */ -/* eslint-disable node/no-extraneous-require */ +/* eslint-disable node/no-extraneous-require -- these are all installed as part of `parcel` */ const bundleReport = require('@parcel/reporter-cli/lib/bundleReport').default; const defaultConfigContents = require('@parcel/config-default'); +const defaultConfigFilePath = require.resolve('@parcel/config-default'); const Parcel = require('@parcel/core').default; const { createWorkerFarm } = require('@parcel/core'); +/* eslint-enable node/no-extraneous-require */ + // TODO: maybe it's worth verifying that all syntaxes are bundled? // Though this is unlikely to change very often. @@ -16,12 +17,10 @@ const config = { browser: { target: { distDir: 'dist' }, entry: 'lib/browser.js', - // dest: 'dist/stylelint-esm.js', }, 'syntax-css-in-js': { target: { distDir: 'dist' }, entry: 'lib/syntaxes/syntax-css-in-js.js', - // dest: 'dist/syntax-css-in-js.js', }, 'syntax-html': { target: { distDir: 'dist' }, @@ -30,36 +29,32 @@ const config = { 'syntax-less': { target: { distDir: 'dist' }, entry: 'lib/syntaxes/syntax-less.js', - // dest: 'dist/syntax-less.js', }, 'syntax-markdown': { target: { distDir: 'dist' }, entry: 'lib/syntaxes/syntax-markdown.js', - // dest: 'dist/syntax-markdown.js', }, 'syntax-sass': { target: { distDir: 'dist' }, entry: 'lib/syntaxes/syntax-sass.js', - // dest: 'dist/syntax-sass.js', }, 'syntax-scss': { target: { distDir: 'dist' }, entry: 'lib/syntaxes/syntax-scss.js', - // dest: 'dist/syntax-scss.js', }, 'syntax-sugarss': { target: { distDir: 'dist' }, entry: 'lib/syntaxes/syntax-sugarss.js', - // dest: 'dist/syntax-sugarss.js', }, }; -let tasks = []; - // Workers have a startup cost. We can keep the workers around between runs, // then shut them down when all bundles have been created. let workerFarm = createWorkerFarm(); +let tasks = []; + +// eslint-disable-next-line guard-for-in -- meh for (const module in config) { let task = async () => { let bundler = new Parcel({ @@ -67,7 +62,7 @@ for (const module in config) { targets: { [module]: config[module].target }, defaultConfig: { ...defaultConfigContents, - filePath: require.resolve('@parcel/config-default'), + filePath: defaultConfigFilePath, }, defaultEngines: { browsers: ['> 0.25%'], @@ -85,7 +80,7 @@ for (const module in config) { const bundleGraph = await bundler.run(); const options = bundler._getResolvedParcelOptions(); // hackety hack. Not a public API - // log stats. This is similar to setting `logLevel: verbose`, but skips the progress spinner + // log stats to console. This is similar to setting `logLevel: verbose`, but skips the progress spinner to avoid unnecessary output await bundleReport(bundleGraph, options.outputFS, options.projectRoot, options.detailedReport); return bundleGraph; @@ -100,23 +95,8 @@ for (const module in config) { await task(); } } catch (error) { - console.error(error); + console.error(error); // eslint-disable-line no-console } finally { await workerFarm.end(); // finished bundling, so we can shut the farm. } })(); - -/* eslint-enable no-console */ -/* eslint-enable guard-for-in */ -/* eslint-enable node/no-extraneous-require */ - -// tasks = [ -// async () => { -// await new Promise((resolve) => setTimeout(resolve, 1000)); -// console.log(`waited: 1000ms`); -// }, -// async () => { -// await new Promise((resolve) => setTimeout(resolve, 500)); -// console.log(`waited: 500ms`); -// }, -// ];