Skip to content

Commit 9c36cae

Browse files
committed
fix: compiler browser support
1 parent c5fc0df commit 9c36cae

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

.changeset/large-bugs-obey.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@marko/compiler": patch
3+
---
4+
5+
Fix regression that prevented loading @marko/compiler in the browser.

packages/compiler/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@
108108
"default": "./dist/register.js"
109109
},
110110
"./modules": "./modules.js",
111-
"./internal/babel": "./dist/babel.js",
111+
"./internal/babel": {
112+
"browser": "./dist/babel.web.js",
113+
"default": "./dist/babel.js"
114+
},
112115
"./babel-types": "./babel-types.d.ts",
113116
"./dist/types": "./dist/types.d.ts",
114117
"./package": "./package.json",

packages/compiler/scripts/bundle-babel.mts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@ import path from "node:path";
22

33
import { build } from "rolldown";
44

5-
await build({
6-
cwd: path.join(import.meta.dirname, ".."),
7-
input: "internal/babel/index.ts",
8-
platform: "node",
9-
external: ["browserslist"],
10-
output: {
11-
format: "cjs",
12-
sourcemap: false,
13-
file: "dist/babel.js",
14-
intro: "'use strict';",
15-
},
16-
});
5+
await Promise.all(
6+
(["browser", "node"] as const).map((platform) =>
7+
build({
8+
platform,
9+
input: "internal/babel/index.ts",
10+
cwd: path.join(import.meta.dirname, ".."),
11+
external: ["browserslist", "path", "assert", "fs"],
12+
output: {
13+
sourcemap: false,
14+
minify: "dce-only",
15+
format: "cjs",
16+
intro: "'use strict';",
17+
file: platform === "node" ? "dist/babel.js" : "dist/babel.web.js",
18+
},
19+
}),
20+
),
21+
);

packages/runtime-tags/scripts/bundle.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ await Promise.all(
2828
output: {
2929
format: "cjs",
3030
sourcemap: false,
31+
minify: "dce-only",
3132
dir: "dist/translator",
3233
intro: "'use strict';",
3334
},
@@ -65,6 +66,7 @@ await Promise.all(
6566
output: {
6667
format,
6768
sourcemap: false,
69+
minify: "dce-only",
6870
file: `${env}/${name}.${format === "esm" ? "mjs" : "js"}`,
6971
intro: format === "cjs" ? "'use strict';" : undefined,
7072
},

0 commit comments

Comments
 (0)