Skip to content

Commit

Permalink
TypeScript 5.2, use tshy for hybrid builds
Browse files Browse the repository at this point in the history
This is a massive patch, but only a few things have really changed.

TypeScript upgraded to version 5.2, which has new and more restrictive
behaviors around module loading and ESM/CommonJS dialect emitting.

To work around this, and provide a simpler and more consistent build
experience, tshy is now used to build all modules, the built Test code,
and used in the @tapjs/create-plugin initializer for use in future
plugins.

The dist directories are thus renamed from `mjs` and `cjs` to the more
comprehensible `esm` and `commonjs`. This is a no-op for most users, but
it did mean a lot of edits to import paths in tests.

A shortcoming that was surfaced by the build change showed that it was
possible to add a plugin that can _only_ be loaded by `require()`, and
not by `import()`. This is now detected, and the plugin addition is
prevented in that case.
  • Loading branch information
isaacs committed Sep 13, 2023
1 parent de09096 commit 0f27f73
Show file tree
Hide file tree
Showing 776 changed files with 2,307 additions and 3,346 deletions.
4 changes: 3 additions & 1 deletion .gitignore
@@ -1,7 +1,10 @@
/node_modules
/docs
/src/*/.tshy
/src/*/.tshy-build-tmp
/src/*/node_modules
/src/*/.tap
/.tap
/src/*/docs
/src/*/dist
!/src/test/dist
Expand All @@ -10,4 +13,3 @@
/tap-snapshots
/.tap
/src/*/.tap
/src/core/scratchpad/.tap
65 changes: 38 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -22,7 +22,7 @@
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
"@esbuild-kit/cjs-loader": "^2.4.2",
"@esbuild-kit/esm-loader": "^2.5.5",
"@tapjs/processinfo": "^3.1.0",
"@tapjs/processinfo": "^3.1.1",
"@types/diff": "^5.0.3",
"@types/ms": "^0.7.31",
"@types/mustache": "^4.2.2",
Expand Down Expand Up @@ -82,8 +82,9 @@
"tap": "^18.0.0-0",
"trivial-deferred": "^2.0.0",
"ts-node": "npm:@isaacs/ts-node-temp-fork-for-pr-2009@^10.9.1",
"tshy": "^1.0.0-3",
"typedoc": "^0.25.1",
"typescript": "5.1",
"typescript": "5.2",
"walk-up-path": "^3.0.1",
"which": "^4.0.0",
"yaml": "^2.3.1",
Expand Down
21 changes: 12 additions & 9 deletions src/after-each/package.json
Expand Up @@ -4,26 +4,23 @@
"description": "a built-in tap extension for t.afterEach()",
"type": "module",
"exports": {
"./package.json": {
"import": "./package.json",
"require": "./package.json"
},
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/mjs/index.d.ts",
"default": "./dist/mjs/index.js"
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"files": [
"dist"
],
"scripts": {
"prepare": "tsc -p tsconfig/cjs.json && tsc -p tsconfig/esm.json && bash ./scripts/fixup.sh",
"prepare": "tshy",
"pretest": "npm run prepare",
"presnap": "npm run prepare",
"test": "tap",
Expand Down Expand Up @@ -55,5 +52,11 @@
"repository": {
"type": "git",
"url": "git+https://github.com/tapjs/tapjs.git"
},
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
}
}
}
16 changes: 0 additions & 16 deletions src/after-each/scripts/fixup.sh

This file was deleted.

2 changes: 1 addition & 1 deletion src/after-each/test/index.ts
@@ -1,7 +1,7 @@
import t from 'tap'

import { Test, TestOpts } from '@tapjs/test'
import { plugin } from '../dist/mjs/index.js'
import { plugin } from '../dist/esm/index.js'

t.equal(t.pluginLoaded(plugin), true, 'plugin is loaded')

Expand Down
12 changes: 6 additions & 6 deletions src/after-each/tsconfig.json
@@ -1,18 +1,18 @@
{
"compilerOptions": {
"rootDir": "./src",
"jsx": "react",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node16",
"inlineSources": true,
"jsx": "react",
"module": "nodenext",
"moduleResolution": "nodenext",
"noUncheckedIndexedAccess": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "es2022",
"module": "esnext"
"target": "es2022"
}
}
10 changes: 0 additions & 10 deletions src/after-each/tsconfig/build.json

This file was deleted.

7 changes: 0 additions & 7 deletions src/after-each/tsconfig/cjs.json

This file was deleted.

7 changes: 0 additions & 7 deletions src/after-each/tsconfig/esm.json

This file was deleted.

2 changes: 1 addition & 1 deletion src/after-each/typedoc.json
@@ -1,5 +1,5 @@
{
"extends": ["../../typedoc.base.json"],
"tsconfig": "./tsconfig/esm.json",
"tsconfig": "./.tshy/esm.json",
"entryPoints": ["./src/**/*.+(ts|tsx|mts)"]
}
3 changes: 0 additions & 3 deletions src/after/dist/cjs/package.json

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/after/dist/commonjs/package.json
@@ -0,0 +1 @@
{"type":"commonjs"}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/after/dist/esm/package.json
@@ -0,0 +1 @@
{"type":"module"}
3 changes: 0 additions & 3 deletions src/after/dist/mjs/package.json

This file was deleted.

21 changes: 12 additions & 9 deletions src/after/package.json
Expand Up @@ -4,26 +4,23 @@
"description": "a built-in tap extension for t.after() and t.teardown()",
"type": "module",
"exports": {
"./package.json": {
"import": "./package.json",
"require": "./package.json"
},
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/mjs/index.d.ts",
"default": "./dist/mjs/index.js"
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"files": [
"dist"
],
"scripts": {
"prepare": "tsc -p tsconfig/cjs.json && tsc -p tsconfig/esm.json && bash ./scripts/fixup.sh",
"prepare": "tshy",
"pretest": "npm run prepare",
"presnap": "npm run prepare",
"test": "tap",
Expand Down Expand Up @@ -55,5 +52,11 @@
},
"dependencies": {
"is-actual-promise": "^1.0.0"
},
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
}
}
}

0 comments on commit 0f27f73

Please sign in to comment.