-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into remove-eol-node-versions
- Loading branch information
Showing
8 changed files
with
14,274 additions
and
3,444 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,76 @@ | ||
import esbuild from "esbuild"; | ||
import { copyFile, readFile, writeFile, rm } from "fs/promises"; | ||
import { glob } from "glob"; | ||
|
||
const sharedOptions = { | ||
sourcemap: "external", | ||
sourcesContent: true, | ||
minify: false, | ||
allowOverwrite: true, | ||
packages: "external", | ||
}; | ||
|
||
async function main() { | ||
// Start with a clean slate | ||
await rm("pkg", { recursive: true, force: true }); | ||
// Build the source code for a neutral platform as ESM | ||
await esbuild.build({ | ||
entryPoints: await glob(["./src/*.ts", "./src/**/*.ts"]), | ||
outdir: "pkg/dist-src", | ||
bundle: false, | ||
platform: "neutral", | ||
format: "esm", | ||
...sharedOptions, | ||
sourcemap: false, | ||
}); | ||
|
||
await Promise.all([ | ||
// Build the a CJS Node.js bundle | ||
esbuild.build({ | ||
entryPoints: ["./pkg/dist-src/index.js"], | ||
outdir: "pkg/dist-node", | ||
bundle: true, | ||
platform: "node", | ||
target: "node14", | ||
format: "cjs", | ||
...sharedOptions, | ||
}), | ||
// Build an ESM browser bundle | ||
esbuild.build({ | ||
entryPoints: [{ in: "./pkg/dist-src/web.js", out: "index" }], | ||
outdir: "pkg/dist-web", | ||
bundle: true, | ||
platform: "browser", | ||
format: "esm", | ||
...sharedOptions, | ||
}), | ||
]); | ||
|
||
// Copy the README, LICENSE to the pkg folder | ||
await copyFile("LICENSE", "pkg/LICENSE"); | ||
await copyFile("README.md", "pkg/README.md"); | ||
|
||
// Handle the package.json | ||
let pkg = JSON.parse((await readFile("package.json", "utf8")).toString()); | ||
// Remove unnecessary fields from the package.json | ||
delete pkg.scripts; | ||
delete pkg.prettier; | ||
delete pkg.release; | ||
await writeFile( | ||
"pkg/package.json", | ||
JSON.stringify( | ||
{ | ||
...pkg, | ||
files: ["dist-*/**"], | ||
main: "dist-node/index.js", | ||
browser: "dist-web/index.js", | ||
types: "dist-types/index.d.ts", | ||
module: "dist-src/index.js", | ||
sideEffects: false, | ||
}, | ||
null, | ||
2 | ||
) | ||
); | ||
} | ||
main(); |
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,9 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"emitDeclarationOnly": false, | ||
"noEmit": true, | ||
"verbatimModuleSyntax": false | ||
}, | ||
"include": ["src/**/*"] | ||
} |
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 +1,11 @@ | ||
{ "extends": "@octokit/tsconfig", "include": ["src/**/*"] } | ||
{ | ||
"extends": "@octokit/tsconfig", | ||
"compilerOptions": { | ||
"esModuleInterop": true, | ||
"declaration": true, | ||
"outDir": "pkg/dist-types", | ||
"emitDeclarationOnly": true, | ||
"sourceMap": true | ||
}, | ||
"include": ["src/**/*"] | ||
} |