-
-
Notifications
You must be signed in to change notification settings - Fork 12
feat: Publish dual CJS and ESM builds #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
d02c6f4
aa1f587
969eabf
7cc6cc7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import {mkdirSync, writeFileSync} from 'node:fs'; | ||
|
|
||
| for (const [dir, type] of [ | ||
| ['build/esm', 'module'], | ||
| ['build/cjs', 'commonjs'], | ||
| ]) { | ||
| mkdirSync(dir, {recursive: true}); | ||
| writeFileSync(`${dir}/package.json`, `${JSON.stringify({type}, null, 2)}\n`); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| const assert = require('node:assert/strict'); | ||
| const {test} = require('node:test'); | ||
| // Requires the package by name (rather than a build path) so this exercises the same | ||
| // "exports"/"main" resolution real CommonJS consumers go through. | ||
| const asyncbox = require('asyncbox'); | ||
|
|
||
| test('require() interop with the CJS build', async () => { | ||
| assert.equal(typeof asyncbox.sleep, 'function'); | ||
| assert.equal(typeof asyncbox.retry, 'function'); | ||
| await asyncbox.sleep(1); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/tsconfig", | ||
| "extends": "./tsconfig.json", | ||
| "compilerOptions": { | ||
| "outDir": "build/cjs", | ||
| "module": "CommonJS", | ||
| "moduleResolution": "Bundler" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/tsconfig", | ||
| "extends": "./tsconfig.json", | ||
| "compilerOptions": { | ||
| "outDir": "build/esm" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,12 +3,12 @@ | |
| "extends": "@appium/tsconfig/tsconfig.json", | ||
| "compilerOptions": { | ||
| "strict": true, | ||
| "outDir": "build", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be removed? The equivalent
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. asyncbox could drop it because it has no lint:types script — only tsc -b via the esm/cjs configs, which both set their own outDir. teen_process's lint:types needs the base config to still emit somewhere sane, so outDir: "build" here is intentional, not leftover cruft. |
||
| "types": ["node"], | ||
| "checkJs": true | ||
| }, | ||
| "include": [ | ||
| "lib", | ||
| "test" | ||
| ] | ||
| ], | ||
| "exclude": ["test/*.cjs"] | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.