Skip to content
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

build esm files to separate folder #684

Merged
merged 1 commit into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"description": "Super-fast alternative to Babel for when you can target modern JS runtimes",
"author": "Alan Pierce <alangpierce@gmail.com>",
"license": "MIT",
"main": "dist/index",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"bin": {
"sucrase": "./bin/sucrase",
"sucrase-node": "./bin/sucrase-node"
Expand Down
10 changes: 3 additions & 7 deletions script/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,15 @@ async function buildSucrase(): Promise<void> {
// code again. The second and third outputs should be exactly identical; otherwise we may have a
// problem where it miscompiled itself.
await run(`${SUCRASE_SELF} ./src -d ./dist-self-build --transforms imports,typescript -q`);
await run(
`${SUCRASE_SELF} ./src -d ./dist-self-build --transforms typescript --out-extension mjs -q`,
);
await run(`${SUCRASE_SELF} ./src -d ./dist-self-build/esm --transforms typescript -q`);
await run("rm -rf ./dist");
await run("mv ./dist-self-build ./dist");
await run(`${SUCRASE_SELF} ./src -d ./dist-self-build --transforms imports,typescript -q`);
await run(
`${SUCRASE_SELF} ./src -d ./dist-self-build --transforms typescript --out-extension mjs -q`,
);
await run(`${SUCRASE_SELF} ./src -d ./dist-self-build/esm --transforms typescript -q`);
await run("diff -r ./dist ./dist-self-build");
// Also add in .d.ts files from tsc, which only need to be compiled once.
await run(`${TSC} --project ./src --outDir ./dist-types`);
await mergeDirectoryContents("./dist-types/src", "./dist");
await mergeDirectoryContents("./dist-types/src", "./dist/types");
// Link all integrations to Sucrase so that all building/linting/testing is up to date.
await run("yarn link");
}
Expand Down
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ export type SourceMapOptions = import("./Options").SourceMapOptions;
export type Transform = import("./Options").Transform;

export function getVersion(): string {
// eslint-disable-next-line
return require("../package.json").version;
return "3.20.3";
}

export function transform(code: string, options: Options): TransformResult {
Expand Down