Skip to content

Commit

Permalink
fix: __esModule is missing from published @babel/parser (#15935)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicol貌 Ribaudo <nicolo.ribaudo@gmail.com>
  • Loading branch information
liuxingbaoyu and nicolo-ribaudo committed Sep 6, 2023
1 parent ff4f959 commit 9b700f4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ function buildRollup(packages, buildStandalone) {

const outputFile = path.join(src, dest, filename || "index.js");
await bundle.write({
esModule: true,
file: outputFile,
format,
name,
Expand Down Expand Up @@ -557,6 +558,7 @@ function buildRollup(packages, buildStandalone) {
await bundle.write({
file: outputFile.replace(/\.js$/, ".min.js"),
format,
esModule: true,
interop: "compat",
name,
sourcemap: sourcemap,
Expand Down
1 change: 0 additions & 1 deletion packages/babel-parser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
tt as internalTokenTypes,
type InternalTokenTypes,
} from "./tokenizer/types.ts";
import "./tokenizer/context.ts";

import type { Expression, File } from "./types.ts";

Expand Down
12 changes: 12 additions & 0 deletions packages/babel-parser/test/commonjs.bundled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { itNoESM, itESM, commonJS } from "$repo-utils";

describe("commonjs bundle", () => {
itESM("dummy", () => {});

itNoESM("has an __esModule export", () => {
const { require } = commonJS(import.meta.url);

// This will require the bundle when running the tests when publishing
expect(require("../lib/index.js").__esModule).toBe(true);
});
});

0 comments on commit 9b700f4

Please sign in to comment.