forked from kt3k/packup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundlet_test.ts
42 lines (40 loc) 路 1.35 KB
/
bundlet_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { assert, assertEquals, assertStringIncludes } from "./test_deps.ts";
import { bundlet, confRules, fm } from "./bundlet.ts";
import { bundleByEsbuild } from "./bundle_util.ts";
Deno.test({
name: "bundlet - bundles module with comment",
fn: async () => {
const tempdir = await Deno.makeTempDir();
const flpath = "./testdata/bundle-examples.js";
const { options, plugins } = await bundlet(flpath, ".", tempdir);
const bundle = await bundleByEsbuild(flpath, options, plugins);
assert(/\/baz\.\w{32}\.js/.test(bundle));
assert(/\/bar\.\w{32}\.js/.test(bundle));
assertStringIncludes(bundle, "https://cdn.skypack.dev/three");
await Deno.remove(tempdir, { recursive: true });
},
sanitizeResources: false,
sanitizeOps: false,
});
Deno.test({
name: "bundlet - bundles mapping",
fn: async () => {
const body = `// !bundle=off
import * as THREE from "https://cdn.skypack.dev/three";
console.log(THREE);
`;
const tempdir = await Deno.makeTempDir();
const fileFree = {};
const result = await confRules(body, {
flpath: "testing.js",
pathPrefix: ".",
distDir: tempdir,
fileFree,
});
assertEquals(fm["three"], "https://cdn.skypack.dev/three");
console.log(result, fileFree, fm);
await Deno.remove(tempdir, { recursive: true });
},
sanitizeResources: false,
sanitizeOps: false,
});