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

Export babel tooling packages in @babel/standalone #11696

Merged
merged 1 commit into from Feb 28, 2024
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
5 changes: 5 additions & 0 deletions packages/babel-standalone/package.json
Expand Up @@ -11,6 +11,8 @@
],
"devDependencies": {
"@babel/core": "workspace:^",
"@babel/generator": "workspace:^",
"@babel/parser": "workspace:^",
"@babel/plugin-external-helpers": "workspace:^",
"@babel/plugin-proposal-decorators": "workspace:^",
"@babel/plugin-proposal-destructuring-private": "workspace:^",
Expand Down Expand Up @@ -115,6 +117,9 @@
"@babel/preset-flow": "workspace:^",
"@babel/preset-react": "workspace:^",
"@babel/preset-typescript": "workspace:^",
"@babel/template": "workspace:^",
"@babel/traverse": "workspace:^",
"@babel/types": "workspace:^",
"acorn": "^8.7.0",
"jsdom": "^22.1.0"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/babel-standalone/src/index.ts
Expand Up @@ -30,6 +30,8 @@ import type { InputOptions } from "@babel/core";

import { runScripts } from "./transformScriptTags.ts";

export * as packages from "./packages.ts";

// We import this file from another package using a relative path because it's
// meant to just be build-time script; it's ok because @babel/standalone is
// bundled anyway.
Expand Down
5 changes: 5 additions & 0 deletions packages/babel-standalone/src/packages.ts
@@ -0,0 +1,5 @@
export * as generator from "@babel/generator";
export * as parser from "@babel/parser";
export * as template from "@babel/template";
export * as traverse from "@babel/traverse";
export * as types from "@babel/types";
20 changes: 20 additions & 0 deletions packages/babel-standalone/test/babel.js
Expand Up @@ -8,6 +8,26 @@ describe("@babel/standalone", () => {
Babel = require("../babel.js");
});

describe("export packages", () => {
it("list", () => {
expect(Object.keys(Babel.packages)).toMatchInlineSnapshot(`
Array [
"generator",
"parser",
"template",
"traverse",
"types",
]
`);
});

it("they work", () => {
const generate = Babel.packages.generator.default;
const parser = Babel.packages.parser;
expect(generate(parser.parse("foo")).code).toBe("foo;");
});
});

it("handles the es2015-no-commonjs preset", () => {
const output = Babel.transform('const getMessage = () => "Hello World"', {
presets: ["es2015-no-commonjs"],
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -4148,6 +4148,8 @@ __metadata:
resolution: "@babel/standalone@workspace:packages/babel-standalone"
dependencies:
"@babel/core": "workspace:^"
"@babel/generator": "workspace:^"
"@babel/parser": "workspace:^"
"@babel/plugin-external-helpers": "workspace:^"
"@babel/plugin-proposal-decorators": "workspace:^"
"@babel/plugin-proposal-destructuring-private": "workspace:^"
Expand Down Expand Up @@ -4252,6 +4254,9 @@ __metadata:
"@babel/preset-flow": "workspace:^"
"@babel/preset-react": "workspace:^"
"@babel/preset-typescript": "workspace:^"
"@babel/template": "workspace:^"
"@babel/traverse": "workspace:^"
"@babel/types": "workspace:^"
acorn: "npm:^8.7.0"
jsdom: "npm:^22.1.0"
languageName: unknown
Expand Down