fix: error bundling JSR islands (#2552)
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
"@astral/astral": "jsr:@astral/astral@^0.4.0",
|
"@astral/astral": "jsr:@astral/astral@^0.4.0",
|
||||||
"@fresh/plugin-tailwind": "./plugin-tailwindcss/src/mod.ts",
|
"@fresh/plugin-tailwind": "./plugin-tailwindcss/src/mod.ts",
|
||||||
"@luca/esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.10.3",
|
"@luca/esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.10.3",
|
||||||
|
"@marvinh-test/fresh-island": "jsr:@marvinh-test/fresh-island@^0.0.1",
|
||||||
"@preact/signals": "npm:@preact/signals@^1.2.3",
|
"@preact/signals": "npm:@preact/signals@^1.2.3",
|
||||||
"@std/async": "jsr:@std/async@^0.224.1",
|
"@std/async": "jsr:@std/async@^0.224.1",
|
||||||
"@std/cli": "jsr:@std/cli@^0.224.5",
|
"@std/cli": "jsr:@std/cli@^0.224.5",
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
"jsr:@astral/astral@^0.4.0": "jsr:@astral/astral@0.4.0",
|
"jsr:@astral/astral@^0.4.0": "jsr:@astral/astral@0.4.0",
|
||||||
"jsr:@deno-library/progress@1.4.9": "jsr:@deno-library/progress@1.4.9",
|
"jsr:@deno-library/progress@1.4.9": "jsr:@deno-library/progress@1.4.9",
|
||||||
"jsr:@luca/esbuild-deno-loader@^0.10.3": "jsr:@luca/esbuild-deno-loader@0.10.3",
|
"jsr:@luca/esbuild-deno-loader@^0.10.3": "jsr:@luca/esbuild-deno-loader@0.10.3",
|
||||||
|
"jsr:@marvinh-test/fresh-island": "jsr:@marvinh-test/fresh-island@0.0.1",
|
||||||
|
"jsr:@marvinh-test/fresh-island@^0.0.1": "jsr:@marvinh-test/fresh-island@0.0.1",
|
||||||
"jsr:@std/assert@^0.213.1": "jsr:@std/assert@0.213.1",
|
"jsr:@std/assert@^0.213.1": "jsr:@std/assert@0.213.1",
|
||||||
"jsr:@std/assert@^0.223.0": "jsr:@std/assert@0.223.0",
|
"jsr:@std/assert@^0.223.0": "jsr:@std/assert@0.223.0",
|
||||||
"jsr:@std/assert@^0.225.3": "jsr:@std/assert@0.225.3",
|
"jsr:@std/assert@^0.225.3": "jsr:@std/assert@0.225.3",
|
||||||
@@ -78,6 +80,13 @@
|
|||||||
"jsr:@std/path@0.213"
|
"jsr:@std/path@0.213"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"@marvinh-test/fresh-island@0.0.1": {
|
||||||
|
"integrity": "890f2595e60b1aaeaa8d73c6ad2c1247d4c5b895387df230f7f3b2a4da29b585",
|
||||||
|
"dependencies": [
|
||||||
|
"npm:@preact/signals@^1.2.3",
|
||||||
|
"npm:preact@^10.22.0"
|
||||||
|
]
|
||||||
|
},
|
||||||
"@std/assert@0.213.1": {
|
"@std/assert@0.213.1": {
|
||||||
"integrity": "24c28178b30c8e0782c18e8e94ea72b16282207569cdd10ffb9d1d26f2edebfe"
|
"integrity": "24c28178b30c8e0782c18e8e94ea72b16282207569cdd10ffb9d1d26f2edebfe"
|
||||||
},
|
},
|
||||||
@@ -1692,6 +1701,7 @@
|
|||||||
"dependencies": [
|
"dependencies": [
|
||||||
"jsr:@astral/astral@^0.4.0",
|
"jsr:@astral/astral@^0.4.0",
|
||||||
"jsr:@luca/esbuild-deno-loader@^0.10.3",
|
"jsr:@luca/esbuild-deno-loader@^0.10.3",
|
||||||
|
"jsr:@marvinh-test/fresh-island@^0.0.1",
|
||||||
"jsr:@std/async@^0.224.1",
|
"jsr:@std/async@^0.224.1",
|
||||||
"jsr:@std/cli@^0.224.5",
|
"jsr:@std/cli@^0.224.5",
|
||||||
"jsr:@std/crypto@1.0.0-rc.1",
|
"jsr:@std/crypto@1.0.0-rc.1",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { expect } from "@std/expect";
|
|||||||
import * as path from "@std/path";
|
import * as path from "@std/path";
|
||||||
import { Builder } from "./builder.ts";
|
import { Builder } from "./builder.ts";
|
||||||
import { App } from "../app.ts";
|
import { App } from "../app.ts";
|
||||||
|
import { RemoteIsland } from "@marvinh-test/fresh-island";
|
||||||
|
|
||||||
Deno.test({
|
Deno.test({
|
||||||
name: "Builder - chain onTransformStaticFile",
|
name: "Builder - chain onTransformStaticFile",
|
||||||
@@ -64,3 +65,26 @@ Deno.test({
|
|||||||
expect(css).toContain('body { background: url("/foo.jpg?__frsh_c=');
|
expect(css).toContain('body { background: url("/foo.jpg?__frsh_c=');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test({
|
||||||
|
name: "Builder - can bundle islands from JSR",
|
||||||
|
fn: async () => {
|
||||||
|
const builder = new Builder();
|
||||||
|
const tmp = await Deno.makeTempDir();
|
||||||
|
const app = new App({
|
||||||
|
staticDir: tmp,
|
||||||
|
build: {
|
||||||
|
outDir: path.join(tmp, "dist"),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
app.island("jsr:@marvinh-test/fresh-island", "RemoteIsland", RemoteIsland);
|
||||||
|
|
||||||
|
await builder.build(app);
|
||||||
|
|
||||||
|
const code = await Deno.readTextFile(
|
||||||
|
path.join(tmp, "dist", "static", "RemoteIsland.js"),
|
||||||
|
);
|
||||||
|
expect(code).toContain('"remote-island"');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|||||||
+13
-1
@@ -110,7 +110,19 @@ export async function bundleJs(
|
|||||||
dependencies.set(entryPath, imports);
|
dependencies.set(entryPath, imports);
|
||||||
|
|
||||||
if (entryPath !== "fresh-runtime.js" && entry.entryPoint !== undefined) {
|
if (entryPath !== "fresh-runtime.js" && entry.entryPoint !== undefined) {
|
||||||
const filePath = path.join(options.cwd, entry.entryPoint);
|
let filePath = "";
|
||||||
|
// Resolve back specifiers to original url. This is necessary
|
||||||
|
// to get JSR dependencies to match what we specified as
|
||||||
|
// an entry point to esbuild.
|
||||||
|
if (
|
||||||
|
entry.entryPoint.startsWith("https://") ||
|
||||||
|
entry.entryPoint.startsWith("http://")
|
||||||
|
) {
|
||||||
|
const basename = path.basename(entryPath, path.extname(entryPath));
|
||||||
|
filePath = options.entryPoints[basename];
|
||||||
|
} else {
|
||||||
|
filePath = path.join(options.cwd, entry.entryPoint);
|
||||||
|
}
|
||||||
|
|
||||||
const name = entryToName.get(filePath)!;
|
const name = entryToName.get(filePath)!;
|
||||||
entryToChunk.set(name, entryPath);
|
entryToChunk.set(name, entryPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user