diff --git a/.yarn/versions/5da63084.yml b/.yarn/versions/5da63084.yml new file mode 100644 index 00000000..14576c16 --- /dev/null +++ b/.yarn/versions/5da63084.yml @@ -0,0 +1,2 @@ +releases: + "@fast-check/packaged": minor diff --git a/packages/packaged/bin/packaged.js b/packages/packaged/bin/packaged.js index 411414d1..28f808b1 100755 --- a/packages/packaged/bin/packaged.js +++ b/packages/packaged/bin/packaged.js @@ -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)); diff --git a/packages/packaged/package.json b/packages/packaged/package.json index f88e1f1c..770b085e 100644 --- a/packages/packaged/package.json +++ b/packages/packaged/package.json @@ -2,7 +2,7 @@ "name": "@fast-check/packaged", "description": "Utility package removing any files that will not be part of the final bundle", "version": "0.2.0", - "type": "commonjs", + "type": "module", "main": "lib/packaged.js", "types": "lib/packaged.d.ts", "bin": "./bin/packaged.js", @@ -12,11 +12,11 @@ ], "sideEffects": false, "scripts": { - "build": "yarn build:publish-cjs && yarn build:publish-types", + "build": "yarn build:publish-esm && yarn build:publish-types", "build-ci": "yarn build", "build:publish-types": "tsc -p tsconfig.publish.types.json", - "build:publish-cjs": "tsc -p tsconfig.publish.json", - "test": "jest --verbose", + "build:publish-esm": "tsc -p tsconfig.publish.json --module es2015 --moduleResolution node", + "test": "yarn node --experimental-vm-modules $(yarn bin jest) --verbose", "typecheck": "tsc --noEmit" }, "repository": { diff --git a/packages/packaged/test-types/empty.ts b/packages/packaged/test-types/empty.ts new file mode 100644 index 00000000..a617e52d --- /dev/null +++ b/packages/packaged/test-types/empty.ts @@ -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. diff --git a/packages/packaged/test-types/main.ts b/packages/packaged/test-types/main.mts similarity index 100% rename from packages/packaged/test-types/main.ts rename to packages/packaged/test-types/main.mts