Skip to content

Commit

Permalink
fix(bundle): fix entrypoint resolution on windows (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k authored Jun 21, 2021
1 parent 2d11d56 commit bd42d6b
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 33 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ jobs:
matrix:
deno:
- canary
runs-on: ubuntu-latest
os:
- ubuntu-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: denoland/setup-deno@v1.0.0
with:
deno-version: ${{ matrix.deno }}
- run: make fmt-check
if: matrix.os == 'ubuntu-latest'
- run: make lint
if: matrix.os == 'ubuntu-latest'
- run: make test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
coverage
dist
/.vscode
/.vim

# parcel
.parcel-cache
4 changes: 2 additions & 2 deletions bundle_util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from "./deps.ts";
import { resolve, toFileUrl } from "./deps.ts";
import { logger } from "./logger_util.ts";
import { load } from "https://deno.land/x/esbuild_loader@v0.12.8/mod.ts";
import { denoPlugin } from "https://raw.githubusercontent.com/lucacasonato/esbuild_deno_loader/fa2219c3df9494da6c33e3e4dffb1a33b5cc0345/mod.ts";
Expand All @@ -10,7 +10,7 @@ export async function bundleByEsbuild(
const { build } = await load(wasmPath);

const bundle = await build({
entryPoints: [resolve(path)],
entryPoints: [toFileUrl(resolve(path)).href],
plugins: [denoPlugin()],
bundle: true,
});
Expand Down
1 change: 1 addition & 0 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export {
join,
relative,
resolve,
toFileUrl,
} from "https://deno.land/std@0.95.0/path/mod.ts";
export { ensureDir } from "https://deno.land/std@0.95.0/fs/ensure_dir.ts";
export { parse as parseFlags } from "https://deno.land/std@0.95.0/flags/mod.ts";
Expand Down
16 changes: 13 additions & 3 deletions install_util_test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { assertEquals } from "./test_deps.ts";
import { join } from "./deps.ts";
import { wasmCacheDir } from "./install_util.ts";

Deno.test("wasmCacheDir - returns cache dir for esbuild wasm", () => {
const homedir = (os: typeof Deno.build.os) =>
os === "windows" ? "/userprofile" : "/home/foo";
assertEquals(wasmCacheDir("windows", homedir), "/userprofile/.deno/packup");
assertEquals(wasmCacheDir("linux", homedir), "/home/foo/.deno/packup");
assertEquals(wasmCacheDir("darwin", homedir), "/home/foo/.deno/packup");
assertEquals(
wasmCacheDir("windows", homedir),
join("/userprofile", ".deno/packup"),
);
assertEquals(
wasmCacheDir("linux", homedir),
join("/home/foo", ".deno/packup"),
);
assertEquals(
wasmCacheDir("darwin", homedir),
join("/home/foo", ".deno/packup"),
);
});
1 change: 0 additions & 1 deletion test.js

This file was deleted.

63 changes: 37 additions & 26 deletions util_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
md5,
} from "./util.ts";

const normalize = (p: string) => join(p);

Deno.test("md5 - returns md5 of the given data", () => {
assertEquals(md5("a"), "0cc175b9c0f1b6a831c399e269772661");
assertEquals(md5("b"), "92eb5ffee6ae2fec3ad71c777531578f");
Expand All @@ -16,40 +18,49 @@ Deno.test("md5 - returns md5 of the given data", () => {

Deno.test("getDependencies - returns dependency specifiers", async () => {
const cwd = Deno.cwd();
assertEquals(await getDependencies("testdata/foo.js"), [
"file://" + join(cwd, "testdata/bar.js"),
"file://" + join(cwd, "testdata/baz.js"),
"file://" + join(cwd, "testdata/foo.js"),
"https://deno.land/std@0.95.0/_util/assert.ts",
"https://deno.land/std@0.95.0/_util/os.ts",
"https://deno.land/std@0.95.0/path/_constants.ts",
"https://deno.land/std@0.95.0/path/_interface.ts",
"https://deno.land/std@0.95.0/path/_util.ts",
"https://deno.land/std@0.95.0/path/common.ts",
"https://deno.land/std@0.95.0/path/glob.ts",
"https://deno.land/std@0.95.0/path/mod.ts",
"https://deno.land/std@0.95.0/path/posix.ts",
"https://deno.land/std@0.95.0/path/separator.ts",
"https://deno.land/std@0.95.0/path/win32.ts",
]);
assertEquals(
(await getDependencies("testdata/foo.js")).map(normalize),
[
"file://" + join(cwd, "testdata/bar.js"),
"file://" + join(cwd, "testdata/baz.js"),
"file://" + join(cwd, "testdata/foo.js"),
"https://deno.land/std@0.95.0/_util/assert.ts",
"https://deno.land/std@0.95.0/_util/os.ts",
"https://deno.land/std@0.95.0/path/_constants.ts",
"https://deno.land/std@0.95.0/path/_interface.ts",
"https://deno.land/std@0.95.0/path/_util.ts",
"https://deno.land/std@0.95.0/path/common.ts",
"https://deno.land/std@0.95.0/path/glob.ts",
"https://deno.land/std@0.95.0/path/mod.ts",
"https://deno.land/std@0.95.0/path/posix.ts",
"https://deno.land/std@0.95.0/path/separator.ts",
"https://deno.land/std@0.95.0/path/win32.ts",
].map(normalize),
);
});

Deno.test("getLocalDependencies - returns local dependency specifiers", async () => {
const cwd = Deno.cwd();
assertEquals(await getLocalDependencies("testdata/foo.js"), [
"file://" + join(cwd, "testdata/bar.js"),
"file://" + join(cwd, "testdata/baz.js"),
"file://" + join(cwd, "testdata/foo.js"),
]);
assertEquals(
(await getLocalDependencies("testdata/foo.js")).map(normalize),
[
"file://" + join(cwd, "testdata/bar.js"),
"file://" + join(cwd, "testdata/baz.js"),
"file://" + join(cwd, "testdata/foo.js"),
].map(normalize),
);
});

Deno.test("getLocalDependencyPaths - returns local dependency paths", async () => {
const cwd = Deno.cwd();
assertEquals(await getLocalDependencyPaths("testdata/foo.js"), [
join(cwd, "testdata/bar.js"),
join(cwd, "testdata/baz.js"),
join(cwd, "testdata/foo.js"),
]);
assertEquals(
(await getLocalDependencyPaths("testdata/foo.js")).map(normalize),
[
join(cwd, "testdata/bar.js"),
join(cwd, "testdata/baz.js"),
join(cwd, "testdata/foo.js"),
].map(normalize),
);
});

Deno.test("byteSize", () => {
Expand Down

0 comments on commit bd42d6b

Please sign in to comment.