-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👷(packaged) Move build chain to ESM (#4588)
The build chain of `@fast-check/packaged` has been CommonJS-based since day 1. With ESM moving forward in the ecosystem, it's time to move ourselves to the new standard and adapt our build chains to ESM. Unfortunately it may have some subtle impacts on our users as our package will not be a CJS one offering a ESM fallback anymore. I will rather be the opposite: an ESM package with a fallback to CJS. It implies that we moved ESM related files closer to the root of the package (we could have kept them in esm/) and moved the CJS ones further in the file structure (we had to move them). Another subtle impact is that it would impose our users to run at least Node ≥12.17.0. As such we consider it as a breaking change.
- Loading branch information
Showing
5 changed files
with
39 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
releases: | ||
"@fast-check/packaged": minor |
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 |
---|---|---|
@@ -1,31 +1,33 @@ | ||
/* global process, console, require */ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const { removeNonPublishedFiles } = require('../lib/packaged.js'); | ||
/* global process, console */ | ||
import { removeNonPublishedFiles } from '../lib/packaged.js'; | ||
|
||
const args = process.argv.slice(2); | ||
const help = args.includes('--help') || args.includes('-h'); | ||
if (help) { | ||
console.log('Usages:'); | ||
console.log('- packaged'); | ||
console.log(' Drop any file in the current directory that will not be part of the package'); | ||
console.log(' if published to npm registry'); | ||
console.log('- packaged --dry-run'); | ||
console.log(' No removal, just printing'); | ||
console.log('- packaged --keep-node-modules'); | ||
console.log(' Keep root level node_modules if any'); | ||
return; | ||
} | ||
const dryRun = args.includes('--dry-run'); | ||
const keepNodeModules = args.includes('--keep-node-modules'); | ||
removeNonPublishedFiles('.', { dryRun, keepNodeModules }).then((out) => { | ||
if (dryRun) { | ||
console.log('Those files would have been kept:'); | ||
for (const k of out.kept) { | ||
console.log(`- ${k}`); | ||
} | ||
console.log('Those files would have been removed:'); | ||
for (const r of out.removed) { | ||
console.log(`- ${r}`); | ||
} | ||
function run(args) { | ||
const help = args.includes('--help') || args.includes('-h'); | ||
if (help) { | ||
console.log('Usages:'); | ||
console.log('- packaged'); | ||
console.log(' Drop any file in the current directory that will not be part of the package'); | ||
console.log(' if published to npm registry'); | ||
console.log('- packaged --dry-run'); | ||
console.log(' No removal, just printing'); | ||
console.log('- packaged --keep-node-modules'); | ||
console.log(' Keep root level node_modules if any'); | ||
return; | ||
} | ||
}); | ||
const dryRun = args.includes('--dry-run'); | ||
const keepNodeModules = args.includes('--keep-node-modules'); | ||
removeNonPublishedFiles('.', { dryRun, keepNodeModules }).then((out) => { | ||
if (dryRun) { | ||
console.log('Those files would have been kept:'); | ||
for (const k of out.kept) { | ||
console.log(`- ${k}`); | ||
} | ||
console.log('Those files would have been removed:'); | ||
for (const r of out.removed) { | ||
console.log(`- ${r}`); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
run(process.argv.slice(2)); |
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,2 @@ | ||
// Just to avoid empty mv from complaining in CI. | ||
// Alternatively we could have muted the complaint by passsing some flags to mv but it would have hidden a potentially legit error. |
File renamed without changes.