-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Don't ship type tests (#21300)
- Loading branch information
Showing
9 changed files
with
100 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
const childProcess = require('child_process'); | ||
const path = require('path'); | ||
const { promisify } = require('util'); | ||
const yargs = require('yargs'); | ||
|
||
const exec = promisify(childProcess.exec); | ||
|
||
const validBundles = [ | ||
// legacy build using commonJS modules | ||
'cjs', | ||
// modern build | ||
'es', | ||
// legacy build using ES6 modules | ||
'esm', | ||
]; | ||
|
||
async function run(argv) { | ||
const { bundle, outDir: relativeOutDir, verbose } = argv; | ||
|
||
if (validBundles.indexOf(bundle) === -1) { | ||
throw new TypeError( | ||
`Unrecognized bundle '${bundle}'. Did you mean one of "${validBundles.join('", "')}"?`, | ||
); | ||
} | ||
|
||
const env = { | ||
NODE_ENV: 'production', | ||
BABEL_ENV: bundle, | ||
}; | ||
const babelConfigPath = path.resolve(__dirname, '../babel.config.js'); | ||
const srcDir = path.resolve('./src'); | ||
const outDir = path.resolve( | ||
relativeOutDir, | ||
{ | ||
cjs: '.', | ||
esm: './esm', | ||
es: './es', | ||
}[bundle], | ||
); | ||
|
||
const command = [ | ||
'yarn babel', | ||
'--config-file', | ||
babelConfigPath, | ||
'--extensions', | ||
'".js,.ts"', | ||
srcDir, | ||
'--out-dir', | ||
outDir, | ||
'--ignore', | ||
'"**/*.test.js","**/*.spec.ts","**/*.d.ts"', | ||
].join(' '); | ||
|
||
if (verbose) { | ||
// eslint-disable-next-line no-console | ||
console.log(`running '${command}' with ${JSON.stringify(env)}`); | ||
} | ||
|
||
return exec(command, { env }); | ||
} | ||
|
||
yargs | ||
.command({ | ||
command: '$0 <bundle>', | ||
description: 'build package', | ||
builder: (command) => { | ||
return command | ||
.positional('bundle', { | ||
description: `Valid bundles: "${validBundles.join('" | "')}"`, | ||
type: 'string', | ||
}) | ||
.option('out-dir', { default: './build', type: 'string' }) | ||
.option('verbose', { type: 'boolean' }); | ||
}, | ||
handler: run, | ||
}) | ||
.help() | ||
.strict(true) | ||
.version(false) | ||
.parse(); |