Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

Commit

Permalink
Build esm modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmud committed Aug 11, 2020
1 parent 789855a commit 18b05b1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module.exports = {
},
},
{
files: './scripts/*',
files: ['./scripts/*', './*.config.js'],
rules: {
'no-console': 0,
},
Expand Down
3 changes: 1 addition & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// eslint-disable-next-line no-undef, import/no-extraneous-dependencies
const { getConfig } = require('@airbnb/config-babel');

const config = getConfig({
library: true,
react: true,
next: true,
esm: process.env.BABEL_OUTPUT === 'esm',
node: process.env.NODE_ENV === 'test',
typescript: true,
env: {
Expand All @@ -16,5 +16,4 @@ const config = getConfig({
config.ignore = config.ignore.filter(item => item !== 'node_modules/');
config.ignore.push('node_modules/(?!(vega-lite|lodash-es))');

// eslint-disable-next-line no-undef
module.exports = config;
14 changes: 10 additions & 4 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ const BABEL_CONFIG = '--config-file=../../babel.config.js';
// packages that do not need tsc
const META_PACKAGES = new Set(['demo', 'generator-superset']);

function run(cmd) {
function run(cmd, options) {
console.log(`\n>> ${cmd}\n`);
const [p, ...args] = cmd.split(' ');
const runner = spawnSync;
const { status } = runner(p, args, { stdio: 'inherit' });
const { status } = runner(p, args, { stdio: 'inherit', ...options });
if (status !== 0) {
process.exit(status);
}
Expand Down Expand Up @@ -89,8 +89,14 @@ if (shouldCleanup) {
}

if (shouldRunBabel) {
run(`lerna exec --stream --concurrency 10 --scope ${scope}
-- babel ${BABEL_CONFIG} src --extensions ".ts,.tsx,.js,.jsx" --out-dir lib --copy-files`);
console.log('--- Run babel --------');
const babelCommand = `lerna exec --stream --concurrency 10 --scope ${scope}
-- babel ${BABEL_CONFIG} src --extensions ".ts,.tsx,.js,.jsx" --copy-files`;
run(`${babelCommand} --out-dir lib`);

console.log('--- Run babel esm ---');
// run again with
run(`${babelCommand} --out-dir esm`, { env: { ...process.env, BABEL_OUTPUT: 'esm' } });
}

if (shouldRunTyping) {
Expand Down

0 comments on commit 18b05b1

Please sign in to comment.