diff --git a/src/common/fetch-node.ts b/src/common/fetch-node.ts
index 9aad5dc..a3924c7 100644
--- a/src/common/fetch-node.ts
+++ b/src/common/fetch-node.ts
@@ -41,9 +41,13 @@ function sourceResponse(buffer: string | Buffer) {
return JSON.parse(buffer.toString());
},
arrayBuffer() {
- if (typeof buffer === 'string')
+ if (typeof buffer === "string")
return new TextEncoder().encode(buffer.toString()).buffer;
- return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
+ return new Uint8Array(
+ buffer.buffer,
+ buffer.byteOffset,
+ buffer.byteLength
+ );
},
};
}
diff --git a/src/common/wrapper.ts b/src/common/wrapper.ts
index 4ea7a49..1f5742d 100644
--- a/src/common/wrapper.ts
+++ b/src/common/wrapper.ts
@@ -1,11 +1,11 @@
//@ts-ignore
-import { fetch } from '#fetch';
-import { parse, init } from 'es-module-lexer';
+import { fetch } from "#fetch";
+import { parse, init } from "es-module-lexer";
-export async function getMaybeWrapperUrl (moduleUrl, fetchOpts) {
+export async function getMaybeWrapperUrl(moduleUrl, fetchOpts) {
await init;
const source = await (await fetch(moduleUrl, fetchOpts)).text();
- const [imports,, facade] = parse(source);
+ const [imports, , facade] = parse(source);
if (facade && imports.length) {
try {
return new URL(imports[0].n, moduleUrl).href;
diff --git a/src/generator.ts b/src/generator.ts
index 0942690..5292864 100644
--- a/src/generator.ts
+++ b/src/generator.ts
@@ -43,7 +43,7 @@ import { LockResolutions } from "./install/lock.js";
import { getDefaultProviderStrings, type Provider } from "./providers/index.js";
import * as nodemodules from "./providers/nodemodules.js";
import { Resolver } from "./trace/resolver.js";
-import { getMaybeWrapperUrl } from './common/wrapper.js';
+import { getMaybeWrapperUrl } from "./common/wrapper.js";
// Utility exports for users:
export { analyzeHtml };
@@ -297,7 +297,7 @@ export interface GeneratorOptions {
* Disabled by default.
*/
commonJS?: boolean;
-
+
/**
* Support tracing TypeScript dependencies when generating the import map.
* Disabled by default.
@@ -311,7 +311,14 @@ export interface GeneratorOptions {
}
export interface ModuleAnalysis {
- format: "commonjs" | "esm" | "system" | "json" | "css" | "typescript" | "wasm";
+ format:
+ | "commonjs"
+ | "esm"
+ | "system"
+ | "json"
+ | "css"
+ | "typescript"
+ | "wasm";
staticDeps: string[];
dynamicDeps: string[];
cjsLazyDeps: string[] | null;
@@ -417,11 +424,9 @@ export class Generator {
timeout: 10000,
...fetchOptions,
headers: { "Accept-Encoding": "gzip, br" },
- }
- if (cache === "offline")
- fetchOpts.cache = "force-cache"
- else if (!cache)
- fetchOpts.cache = "no-store";
+ };
+ if (cache === "offline") fetchOpts.cache = "force-cache";
+ else if (!cache) fetchOpts.cache = "no-store";
// Default logic for the mapUrl, baseUrl and rootUrl:
if (mapUrl && !baseUrl) {
@@ -461,7 +466,14 @@ export class Generator {
this.integrity = integrity;
// Initialise the resolver:
- const resolver = new Resolver({ env, log, fetchOpts, preserveSymlinks: true, traceCjs: commonJS, traceTs: typeScript });
+ const resolver = new Resolver({
+ env,
+ log,
+ fetchOpts,
+ preserveSymlinks: true,
+ traceCjs: commonJS,
+ traceTs: typeScript,
+ });
if (customProviders) {
for (const provider of Object.keys(customProviders)) {
resolver.addCustomProvider(provider, customProviders[provider]);
@@ -495,7 +507,7 @@ export class Generator {
providers,
ignore,
resolutions,
- commonJS
+ commonJS,
},
log,
resolver
@@ -503,8 +515,7 @@ export class Generator {
// Reconstruct constraints and locks from the input map:
this.map = new ImportMap({ mapUrl: this.mapUrl, rootUrl: this.rootUrl });
- if (!integrity)
- this.map.integrity = {};
+ if (!integrity) this.map.integrity = {};
if (inputMap) this.addMappings(inputMap);
}
@@ -669,9 +680,7 @@ export class Generator {
" Generated by @jspm/generator - https://github.com/jspm/generator ";
if (typeof htmlUrl === "string") htmlUrl = new URL(htmlUrl);
if (this.installCnt !== 0)
- throw new JspmError(
- "htmlInject cannot run alongside other install ops"
- );
+ throw new JspmError("htmlInject cannot run alongside other install ops");
const analysis = analyzeHtml(html, htmlUrl);
@@ -696,13 +705,16 @@ export class Generator {
);
}
- const preloadDeps = preload === "all" ? [...new Set([...staticDeps, ...dynamicDeps])] : staticDeps;
+ const preloadDeps =
+ preload === "all"
+ ? [...new Set([...staticDeps, ...dynamicDeps])]
+ : staticDeps;
const newlineTab = !whitespace
? analysis.newlineTab
: analysis.newlineTab.includes("\n")
- ? analysis.newlineTab
- : "\n" + analysis.newlineTab;
+ ? analysis.newlineTab
+ : "\n" + analysis.newlineTab;
const replacer = new Replacer(html);
@@ -740,7 +752,10 @@ export class Generator {
)) + "dist/es-module-shims.js";
// detect esmsUrl as a wrapper URL
- esmsUrl = await getMaybeWrapperUrl(esmsUrl, this.traceMap.resolver.fetchOpts);
+ esmsUrl = await getMaybeWrapperUrl(
+ esmsUrl,
+ this.traceMap.resolver.fetchOpts
+ );
if (htmlUrl || rootUrl)
esmsUrl = relativeUrl(
@@ -749,12 +764,17 @@ export class Generator {
!!rootUrl
);
- esms = `${newlineTab}`;
+ esms = `${newlineTab}`;
if (analysis.esModuleShims)
replacer.remove(
@@ -774,14 +794,11 @@ export class Generator {
for (let dep of preloadDeps.sort()) {
if (first || whitespace) preloads += newlineTab;
if (first) first = false;
- preloads += ``;
+ preloads += ``;
}
}
@@ -800,17 +817,17 @@ export class Generator {
analysis.map.start,
analysis.map.end,
(comment ? "" + newlineTab : "") +
- esms +
- '" +
- preloads +
- (analysis.map.newScript ? newlineTab : "")
+ esms +
+ '" +
+ preloads +
+ (analysis.map.newScript ? newlineTab : "")
);
return replacer.source;
@@ -850,7 +867,6 @@ export class Generator {
install?: string | Install | (string | Install)[],
mode?: InstallMode
): Promise {
-
// If there are no arguments, then we reinstall all the top-level locks:
if (install === null || install === undefined) {
await this.traceMap.processInputMap;
@@ -1097,7 +1113,8 @@ export class Generator {
}
this.traceMap.pins = pins;
if (--this.installCnt === 0) {
- const { staticDeps, dynamicDeps, map } = await this.traceMap.finishInstall(this.traceMap.pins, this.integrity);
+ const { staticDeps, dynamicDeps, map } =
+ await this.traceMap.finishInstall(this.traceMap.pins, this.integrity);
this.map = map;
return { staticDeps, dynamicDeps };
}
@@ -1112,7 +1129,7 @@ export class Generator {
if (typeof mapUrl === "string") mapUrl = new URL(mapUrl, this.baseUrl);
if (typeof rootUrl === "string") rootUrl = new URL(rootUrl, this.baseUrl);
if (!Array.isArray(pins)) pins = [pins];
- if (typeof integrity !== 'boolean') integrity = this.integrity;
+ if (typeof integrity !== "boolean") integrity = this.integrity;
if (this.installCnt++ !== 0)
throw new JspmError(`Cannot run extract map during installs`);
this.traceMap.startInstall();
@@ -1374,10 +1391,12 @@ async function installToTarget(
(install.subpath !== "." && !install.subpath.startsWith("./")))
)
throw new Error(
- `Install subpath "${install.subpath
- }" must be a string equal to "." or starting with "./".${typeof install.subpath === "string"
- ? `\nTry setting the subpath to "./${install.subpath}"`
- : ""
+ `Install subpath "${
+ install.subpath
+ }" must be a string equal to "." or starting with "./".${
+ typeof install.subpath === "string"
+ ? `\nTry setting the subpath to "./${install.subpath}"`
+ : ""
}`
);
diff --git a/src/install/installer.ts b/src/install/installer.ts
index 03ea6b2..21ba84d 100644
--- a/src/install/installer.ts
+++ b/src/install/installer.ts
@@ -61,7 +61,7 @@ export type InstallMode =
export type InstallTarget = {
pkgTarget: PackageTarget | URL;
- installSubpath: null | '.' | `./${string}`;
+ installSubpath: null | "." | `./${string}`;
};
export interface InstallerOptions {
diff --git a/src/install/lock.ts b/src/install/lock.ts
index f67c228..f3970d3 100644
--- a/src/install/lock.ts
+++ b/src/install/lock.ts
@@ -52,7 +52,7 @@ export interface VersionConstraints {
export interface InstalledResolution {
installUrl: `${string}/`;
- installSubpath: '.' | `./${string}` | null;
+ installSubpath: "." | `./${string}` | null;
}
export interface FlatInstalledResolution {
@@ -126,7 +126,7 @@ export function setResolution(
name: string,
installUrl: `${string}/`,
pkgScope: `${string}/` | null = null,
- installSubpath: '.' | `./${string}` | null = null
+ installSubpath: "." | `./${string}` | null = null
) {
if (pkgScope && !pkgScope.endsWith("/")) throwInternalError(pkgScope);
if (pkgScope === null) {
@@ -513,7 +513,7 @@ export async function extractLockConstraintsAndMap(
// In the case of subpaths having diverging versions, we force convergence on one version
// Only scopes permit unpacking
- let installSubpath: null | '.' | './' | `./${string}/` | false = null;
+ let installSubpath: null | "." | "./" | `./${string}/` | false = null;
if (parsedKey.subpath !== exportSubpath) {
if (parsedKey.subpath === ".") {
installSubpath = exportSubpath as `./${string}/`;
diff --git a/src/providers/esmsh.ts b/src/providers/esmsh.ts
index 9fc88cc..754c464 100644
--- a/src/providers/esmsh.ts
+++ b/src/providers/esmsh.ts
@@ -13,7 +13,8 @@ export async function pkgToUrl(pkg: ExactPackage): Promise<`${string}/`> {
return `${cdnUrl}*${pkg.name}@${pkg.version}/`;
}
-const exactPkgRegEx = /^(?:v\d+\/)?\*?((?:@[^/\\%@]+\/)?[^./\\%@][^/\\%@]*)@([^\/]+)(\/.*)?$/;
+const exactPkgRegEx =
+ /^(?:v\d+\/)?\*?((?:@[^/\\%@]+\/)?[^./\\%@][^/\\%@]*)@([^\/]+)(\/.*)?$/;
export function parseUrlPkg(url: string) {
if (!url.startsWith(cdnUrl)) return;
@@ -54,17 +55,16 @@ export async function getPackageConfig(
if (pcfg.exports) {
// in the conditional expoort case, paths seem to work?
// so go with that
- if (Object.keys(pcfg.exports).every(key => !key.startsWith('./'))) {
- pcfg.exports['.'] = pcfg.exports;
- }
- else {
+ if (Object.keys(pcfg.exports).every((key) => !key.startsWith("./"))) {
+ pcfg.exports["."] = pcfg.exports;
+ } else {
// let esm.sh resolve conditions
for (const key of Object.keys(pcfg.exports)) {
pcfg.exports[key] = key;
}
}
// wildcard key for esmsh to do its own fallback resolution too
- pcfg.exports['./*'] = './*';
+ pcfg.exports["./*"] = "./*";
}
if (pcfg.imports) {
for (const key of Object.keys(pcfg.imports)) {
diff --git a/src/providers/index.ts b/src/providers/index.ts
index 12e10db..b4556a1 100644
--- a/src/providers/index.ts
+++ b/src/providers/index.ts
@@ -59,7 +59,7 @@ export const defaultProviders: Record = {
skypack,
unpkg,
"esm.sh": esmsh,
- "jspm.io": jspm
+ "jspm.io": jspm,
};
export function getProvider(name: string, providers: Record) {
diff --git a/src/providers/jspm.ts b/src/providers/jspm.ts
index 6e03268..0e95ec0 100644
--- a/src/providers/jspm.ts
+++ b/src/providers/jspm.ts
@@ -284,7 +284,9 @@ async function lookupRange(
);
default:
throw new JspmError(
- `Invalid status code ${res.status} looking up "${registry}:${name}" from ${url} - ${
+ `Invalid status code ${
+ res.status
+ } looking up "${registry}:${name}" from ${url} - ${
res.statusText
}${importedFrom(parentUrl)}`
);
diff --git a/src/providers/node.ts b/src/providers/node.ts
index e709410..53b7b2b 100644
--- a/src/providers/node.ts
+++ b/src/providers/node.ts
@@ -105,8 +105,7 @@ export function resolveBuiltin(
}
// Strip the subpath for subpathed builtins
- if (builtin.includes('/'))
- builtin = builtin.split('/')[0];
+ if (builtin.includes("/")) builtin = builtin.split("/")[0];
return {
target: {
diff --git a/src/trace/analysis.ts b/src/trace/analysis.ts
index 6605549..b1f8d5e 100644
--- a/src/trace/analysis.ts
+++ b/src/trace/analysis.ts
@@ -4,7 +4,14 @@ export interface Analysis {
deps: string[];
dynamicDeps: string[];
cjsLazyDeps: string[] | null;
- format: "esm" | "commonjs" | "system" | "json" | "typescript" | "wasm" | "css";
+ format:
+ | "esm"
+ | "commonjs"
+ | "system"
+ | "json"
+ | "typescript"
+ | "wasm"
+ | "css";
size: number;
// for commonjs format, true iff the module uses a CJS-only global
@@ -46,7 +53,14 @@ export function createEsmAnalysis(
}
}
const size = source.length;
- return { deps, dynamicDeps, cjsLazyDeps: null, size, format: "esm", integrity: getIntegrity(source) };
+ return {
+ deps,
+ dynamicDeps,
+ cjsLazyDeps: null,
+ size,
+ format: "esm",
+ integrity: getIntegrity(source),
+ };
}
const registerRegEx =
@@ -81,5 +95,12 @@ export function createSystemAnalysis(
}
}
const size = source.length;
- return { deps, dynamicDeps, cjsLazyDeps: null, size, format: "system", integrity: getIntegrity(source) };
+ return {
+ deps,
+ dynamicDeps,
+ cjsLazyDeps: null,
+ size,
+ format: "system",
+ integrity: getIntegrity(source),
+ };
}
diff --git a/src/trace/resolver.ts b/src/trace/resolver.ts
index d6151fd..96f41c0 100644
--- a/src/trace/resolver.ts
+++ b/src/trace/resolver.ts
@@ -493,7 +493,10 @@ export class Resolver {
if (subpath !== ".") return null;
const url = new URL(pcfg.exports, pkgUrl).href;
try {
- if ((await this.finalizeResolve(url, false, true, pkgUrl)) === resolvedUrl)
+ if (
+ (await this.finalizeResolve(url, false, true, pkgUrl)) ===
+ resolvedUrl
+ )
return ".";
} catch {}
return null;
@@ -740,12 +743,16 @@ export class Resolver {
else throwExportNotDefined();
} else if (!allDotKeys(pcfg.exports)) {
if (subpath === ".") {
- const url = this.resolvePackageTarget(pcfg.exports, pkgUrl, cjsEnv, "", false);
- if (url === null)
- throwExportNotDefined();
+ const url = this.resolvePackageTarget(
+ pcfg.exports,
+ pkgUrl,
+ cjsEnv,
+ "",
+ false
+ );
+ if (url === null) throwExportNotDefined();
return this.finalizeResolve(url, parentIsCjs, true, pkgUrl);
- }
- else throwExportNotDefined();
+ } else throwExportNotDefined();
} else {
const match = getMapMatch(
subpath,
@@ -885,12 +892,14 @@ export class Resolver {
throw e;
}
return {
- deps: WebAssembly.Module.imports(compiled).map(({ module }) => module),
+ deps: WebAssembly.Module.imports(compiled).map(
+ ({ module }) => module
+ ),
dynamicDeps: [],
cjsLazyDeps: null,
size: source.byteLength,
format: "wasm",
- integrity: getIntegrity(new Uint8Array(source))
+ integrity: getIntegrity(new Uint8Array(source)),
};
}
@@ -913,7 +922,7 @@ export class Resolver {
cjsLazyDeps: null,
size: source.length,
format: "json",
- integrity: getIntegrity(source)
+ integrity: getIntegrity(source),
};
} catch {}
}
@@ -926,7 +935,7 @@ export class Resolver {
cjsLazyDeps: null,
size: source.length,
format: "css",
- integrity: getIntegrity(source)
+ integrity: getIntegrity(source),
};
} catch {}
}
@@ -1003,7 +1012,7 @@ export class Resolver {
packageUrl: string,
cjsEnv: boolean,
subpath: string,
- isImport: boolean,
+ isImport: boolean
): string | null {
if (typeof target === "string") {
if (target === ".") {
diff --git a/src/trace/tracemap.ts b/src/trace/tracemap.ts
index 1f47754..b399d1c 100644
--- a/src/trace/tracemap.ts
+++ b/src/trace/tracemap.ts
@@ -85,7 +85,14 @@ interface TraceEntry {
// For cjs modules, the list of hoisted deps
// this is needed for proper cycle handling
cjsLazyDeps: string[];
- format: "esm" | "commonjs" | "system" | "json" | "css" | "typescript" | "wasm";
+ format:
+ | "esm"
+ | "commonjs"
+ | "system"
+ | "json"
+ | "css"
+ | "typescript"
+ | "wasm";
}
interface VisitOpts {
@@ -296,12 +303,10 @@ export default class TraceMap {
toplevel: boolean,
entry
) => {
- if (!list.has(resolved))
- list.add(resolved);
+ if (!list.has(resolved)) list.add(resolved);
// no entry applies to builtins
if (entry) {
- if (integrity)
- map.setIntegrity(resolved, entry.integrity);
+ if (integrity) map.setIntegrity(resolved, entry.integrity);
for (const dep of entry.dynamicDeps) {
dynamics.push([dep, resolved]);
}
@@ -430,7 +435,12 @@ export default class TraceMap {
);
const resolvedHref = resolvedUrl.href;
let finalized = await this.resolver.realPath(
- await this.resolver.finalizeResolve(resolvedHref, parentIsCjs, false, parentPkgUrl)
+ await this.resolver.finalizeResolve(
+ resolvedHref,
+ parentIsCjs,
+ false,
+ parentPkgUrl
+ )
);
// handle URL mappings
diff --git a/test/api/assets.test.js b/test/api/assets.test.js
index a5bbc3f..b7422dc 100644
--- a/test/api/assets.test.js
+++ b/test/api/assets.test.js
@@ -7,12 +7,17 @@ const generator = new Generator({
env: ["production", "browser"],
});
-await generator.install('@shopify/polaris@13.4.0/build/esm/styles.css');
+await generator.install("@shopify/polaris@13.4.0/build/esm/styles.css");
await generator.install({ target: "./local/assets", subpath: "./css" });
await generator.install({ target: "./local/assets", subpath: "./json" });
await generator.install({ target: "./local/assets", subpath: "./wasm" });
const json = generator.getMap();
-deepStrictEqual(Object.keys(json.imports), ['@shopify/polaris/build/esm/styles.css', 'assets/css', 'assets/json', 'assets/wasm']);
-strictEqual(json.scopes['./local/assets/']['#asdf'], './local/assets/file.js');
+deepStrictEqual(Object.keys(json.imports), [
+ "@shopify/polaris/build/esm/styles.css",
+ "assets/css",
+ "assets/json",
+ "assets/wasm",
+]);
+strictEqual(json.scopes["./local/assets/"]["#asdf"], "./local/assets/file.js");
diff --git a/test/api/install.test.js b/test/api/install.test.js
index caec639..fc1d8c7 100644
--- a/test/api/install.test.js
+++ b/test/api/install.test.js
@@ -15,8 +15,8 @@ const generator = new Generator({
mapUrl: import.meta.url,
env: ["production", "browser"],
resolutions: {
- 'lit': '2.6.1'
- }
+ lit: "2.6.1",
+ },
});
// Install with no arguments should install all top-level pins.
diff --git a/test/api/local/assets/file.js b/test/api/local/assets/file.js
index 1bfe61f..5553a25 100644
--- a/test/api/local/assets/file.js
+++ b/test/api/local/assets/file.js
@@ -1 +1 @@
-export var f = () => 5;
\ No newline at end of file
+export var f = () => 5;
diff --git a/test/api/node.test.js b/test/api/node.test.js
index b065ab1..47253c0 100644
--- a/test/api/node.test.js
+++ b/test/api/node.test.js
@@ -4,12 +4,12 @@ import assert from "assert";
{
const generator = new Generator();
- await generator.link('fs/promises');
+ await generator.link("fs/promises");
const json = generator.getMap();
assert.strictEqual(
- json.imports["fs/promises"].split('/').slice(-4).join('/'),
+ json.imports["fs/promises"].split("/").slice(-4).join("/"),
`nodelibs/browser/fs/promises.js`
);
}
diff --git a/test/deno/self.skip.js b/test/deno/self.skip.js
index 0fa258e..5b09240 100644
--- a/test/deno/self.skip.js
+++ b/test/deno/self.skip.js
@@ -10,7 +10,7 @@ const generator = new Generator({
resolutions: {
"@babel/core": "~7.20.0",
"@babel/generator": "7.20.0",
- "@babel/helper-member-expression-to-functions": "7.20.7"
+ "@babel/helper-member-expression-to-functions": "7.20.7",
},
});
diff --git a/test/html/breaks.test.js b/test/html/breaks.test.js
index 9c2377b..fd12796 100644
--- a/test/html/breaks.test.js
+++ b/test/html/breaks.test.js
@@ -20,8 +20,7 @@ const esmsUrl =
generator.traceMap.installer.defaultProvider
)) + "dist/es-module-shims.js";
-const html =
-`
+const html = `
@@ -66,7 +65,8 @@ const html =
const pins = await generator.addMappings(html);
const res = await generator.htmlInject(html, { pins, preload: true });
-assert.strictEqual(res,
+assert.strictEqual(
+ res,
"\n" +
'\n' +
"\n" +
diff --git a/test/html/emptymap.test.js b/test/html/emptymap.test.js
index 370aeae..77818a5 100644
--- a/test/html/emptymap.test.js
+++ b/test/html/emptymap.test.js
@@ -17,7 +17,7 @@ const esmsUrl =
generator.traceMap.installer.defaultProvider
)) + "dist/es-module-shims.js";
-const html = `
+const html = `
`;
@@ -25,7 +25,8 @@ const html = `
const pins = await generator.addMappings(html);
const res = await generator.htmlInject(html, { pins, preload: true });
-assert.strictEqual(res,
+assert.strictEqual(
+ res,
"\n" +
"\n" +
"\n" +
diff --git a/test/html/esmsh.test.js b/test/html/esmsh.test.js
index d1ea0c1..a9bdf81 100644
--- a/test/html/esmsh.test.js
+++ b/test/html/esmsh.test.js
@@ -5,14 +5,14 @@ import { SemverRange } from "sver";
const generator = new Generator({
mapUrl: new URL("./local/page.html", import.meta.url),
env: ["production", "browser"],
- defaultProvider: 'esm.sh'
+ defaultProvider: "esm.sh",
});
const esmsPkg = await generator.traceMap.resolver.resolveLatestTarget(
{ name: "es-module-shims", registry: "npm", ranges: [new SemverRange("*")] },
generator.traceMap.installer.defaultProvider
);
-let pins, html
+let pins, html;
html = `
@@ -22,4 +22,6 @@ html = `
`;
pins = await generator.addMappings(html);
-assert((await generator.htmlInject(html, { pins })).includes('https://esm.sh/v'));
+assert(
+ (await generator.htmlInject(html, { pins })).includes("https://esm.sh/v")
+);
diff --git a/test/html/inject.test.js b/test/html/inject.test.js
index fd2f7df..7e1efad 100644
--- a/test/html/inject.test.js
+++ b/test/html/inject.test.js
@@ -17,7 +17,7 @@ const esmsUrl =
generator.traceMap.installer.defaultProvider
)) + "dist/es-module-shims.js";
-let pins, html
+let pins, html;
html = `
@@ -26,7 +26,8 @@ html = `
`;
pins = await generator.addMappings(html);
-assert.strictEqual(await generator.htmlInject(html, { pins }),
+assert.strictEqual(
+ await generator.htmlInject(html, { pins }),
"\n" +
"\n" +
"\n" +
@@ -49,29 +50,30 @@ assert.strictEqual(await generator.htmlInject(html, { pins }),
);
// Idempotency:
-html =
- "\n" +
- "\n" +
- "\n" +
- `\n` +
- '\n" +
- '\n";
+html =
+ "\n" +
+ "\n" +
+ "\n" +
+ `\n` +
+ '\n" +
+ '\n";
pins = await generator.addMappings(html);
-assert.strictEqual(await generator.htmlInject(html, { pins }),
+assert.strictEqual(
+ await generator.htmlInject(html, { pins }),
"\n" +
"\n" +
"\n" +
diff --git a/test/html/injectionpoint.test.js b/test/html/injectionpoint.test.js
index cfea9f6..69ac260 100644
--- a/test/html/injectionpoint.test.js
+++ b/test/html/injectionpoint.test.js
@@ -34,7 +34,8 @@ const html = `
const pins = await generator.addMappings(html);
-assert.strictEqual(await generator.htmlInject(html, { pins, preload: true }),
+assert.strictEqual(
+ await generator.htmlInject(html, { pins, preload: true }),
"\n" +
"\n" +
"\n" +
diff --git a/test/html/inline.test.js b/test/html/inline.test.js
index 733b322..e1e36f1 100644
--- a/test/html/inline.test.js
+++ b/test/html/inline.test.js
@@ -29,7 +29,8 @@ const html = `
`;
const pins = await generator.addMappings(html);
-assert.strictEqual(await generator.htmlInject(html, { pins }),
+assert.strictEqual(
+ await generator.htmlInject(html, { pins }),
"\n" +
"\n" +
"\n" +
diff --git a/test/html/lit.test.js b/test/html/lit.test.js
index 049ba32..9924543 100644
--- a/test/html/lit.test.js
+++ b/test/html/lit.test.js
@@ -54,7 +54,8 @@ let html = `
`;
let pins = await generator.addMappings(html);
-assert.strictEqual(await generator.htmlInject(html, { pins, preload: true }),
+assert.strictEqual(
+ await generator.htmlInject(html, { pins, preload: true }),
"\n" +
"\n" +
"\n" +
@@ -107,58 +108,60 @@ assert.strictEqual(await generator.htmlInject(html, { pins, preload: true }),
);
// Idempotency
-html = "\n" +
- "\n" +
- "\n" +
- " \n" +
- ` \n` +
- ' \n" +
- ' \n' +
- ' \n' +
- ' \n' +
- ' \n' +
- ' \n' +
- ' \n" +
- "\n" +
- "\n" +
- ' \n' +
- "\n";
+html =
+ "\n" +
+ "\n" +
+ "\n" +
+ " \n" +
+ ` \n` +
+ ' \n" +
+ ' \n' +
+ ' \n' +
+ ' \n' +
+ ' \n' +
+ ' \n' +
+ ' \n" +
+ "\n" +
+ "\n" +
+ ' \n' +
+ "\n";
pins = await generator.addMappings(html);
-assert.strictEqual(await generator.htmlInject(html, { pins, preload: true }),
+assert.strictEqual(
+ await generator.htmlInject(html, { pins, preload: true }),
"\n" +
"\n" +
"\n" +
diff --git a/test/html/maps.test.js b/test/html/maps.test.js
index d661afa..783dcae 100644
--- a/test/html/maps.test.js
+++ b/test/html/maps.test.js
@@ -35,7 +35,8 @@ const html = `
`;
const pins = await generator.addMappings(html);
-assert.strictEqual(await generator.htmlInject(html, { pins, preload: true }),
+assert.strictEqual(
+ await generator.htmlInject(html, { pins, preload: true }),
"\n" +
"\n" +
"\n" +
@@ -63,30 +64,36 @@ assert.strictEqual(await generator.htmlInject(html, { pins, preload: true }),
});
// Idempotency
- const html = "\n" +
- "\n" +
- `\n` +
- '\n" +
- '\n' +
- '\n' +
- '\n";
+ const html =
+ "\n" +
+ "\n" +
+ `\n` +
+ '\n" +
+ '\n' +
+ '\n' +
+ '\n";
- const pins = await generator.addMappings(html);
- assert.strictEqual(await generator.htmlInject(html, { pins, preload: true, whitespace: false }),
- "\n" +
+ const pins = await generator.addMappings(html);
+ assert.strictEqual(
+ await generator.htmlInject(html, {
+ pins,
+ preload: true,
+ whitespace: false,
+ }),
+ "\n" +
"\n" +
"\n" +
`\n` +
diff --git a/test/html/preload.test.js b/test/html/preload.test.js
index d072f39..059c74c 100644
--- a/test/html/preload.test.js
+++ b/test/html/preload.test.js
@@ -27,11 +27,40 @@ let html = `
`;
let pins = await generator.addMappings(html);
-assert.strictEqual(await generator.htmlInject(html, { pins, integrity: true }),
+assert.strictEqual(
+ await generator.htmlInject(html, { pins, integrity: true }),
+ "\n" +
+ "\n" +
+ "\n" +
+ `\n` +
+ '\n" +
+ '\n"
+);
+
+// Idempotency
+html =
"\n" +
"\n" +
"\n" +
- `\n` +
+ `\n` +
'\n" +
+ '\n' +
+ '\n' +
+ '\n' +
'\n"
-);
-
-// Idempotency
-html = "\n" +
- "\n" +
- "\n" +
- `\n` +
- '\n" +
- '\n' +
- '\n' +
- '\n' +
- '\n";
+ "\n";
pins = await generator.addMappings(html);
-assert.strictEqual(await generator.htmlInject(html, { pins, preload: true, integrity: true, whitespace: false }),
+assert.strictEqual(
+ await generator.htmlInject(html, {
+ pins,
+ preload: true,
+ integrity: true,
+ whitespace: false,
+ }),
"\n" +
"\n" +
"\n" +
diff --git a/test/html/ws.test.js b/test/html/ws.test.js
index 161c6d0..2652e93 100644
--- a/test/html/ws.test.js
+++ b/test/html/ws.test.js
@@ -20,7 +20,6 @@ const esmsUrl =
generator.traceMap.installer.defaultProvider
)) + "dist/es-module-shims.js";
-
let html = `
@@ -28,7 +27,8 @@ let html = `
let pins = await generator.addMappings(html);
-assert.strictEqual(await generator.htmlInject(html, { pins, whitespace: true }),
+assert.strictEqual(
+ await generator.htmlInject(html, { pins, whitespace: true }),
"\n" +
" \n" +
" \n" +
@@ -55,7 +55,8 @@ html = `
pins = await generator.addMappings(html);
-assert.strictEqual(await generator.htmlInject(html, { pins, whitespace: false }),
+assert.strictEqual(
+ await generator.htmlInject(html, { pins, whitespace: false }),
"\n" +
" \n" +
" \n" +
@@ -87,7 +88,8 @@ html = `
pins = await generator.addMappings(html);
-assert.strictEqual(await generator.htmlInject(html, { pins }),
+assert.strictEqual(
+ await generator.htmlInject(html, { pins }),
`
diff --git a/test/providers/customregistry.test.js b/test/providers/customregistry.test.js
index 69b39b0..5e4eea1 100644
--- a/test/providers/customregistry.test.js
+++ b/test/providers/customregistry.test.js
@@ -27,8 +27,8 @@ const generator = new Generator({
if (pcfg.dependencies) {
let dependencies = {};
for (let [name, target] of Object.entries(pcfg.dependencies)) {
- if (target.indexOf(':') === -1)
- target = 'myorg:' + name + '@' + target;
+ if (target.indexOf(":") === -1)
+ target = "myorg:" + name + "@" + target;
dependencies[name] = target;
}
pcfg.dependencies = dependencies;
@@ -37,7 +37,8 @@ const generator = new Generator({
},
parseUrlPkg(url) {
if (url.startsWith(myorgUrl)) {
- const [, name, version] = url.slice(myorgUrl.length).match(exactPkgRegEx) || [];
+ const [, name, version] =
+ url.slice(myorgUrl.length).match(exactPkgRegEx) || [];
return { registry: "myorg", name, version };
}
},
@@ -46,9 +47,15 @@ const generator = new Generator({
layer,
parentUrl
) {
- assert.ok(registry === 'myorg');
- const { resolved: { name: resolvedName, version: resolvedVersion } } = await lookup(`${name}@${range.toString()}`);
- return { registry: 'myorg', name: resolvedName, version: resolvedVersion };
+ assert.ok(registry === "myorg");
+ const {
+ resolved: { name: resolvedName, version: resolvedVersion },
+ } = await lookup(`${name}@${range.toString()}`);
+ return {
+ registry: "myorg",
+ name: resolvedName,
+ version: resolvedVersion,
+ };
},
},
},
@@ -58,6 +65,4 @@ await generator.install("myorg:lit");
const json = generator.getMap();
-assert.ok(
- json.imports.lit.startsWith('https://unpkg.com/lit@')
-);
+assert.ok(json.imports.lit.startsWith("https://unpkg.com/lit@"));
diff --git a/test/providers/deno.skipbrowser.test.js b/test/providers/deno.skipbrowser.test.js
index b6535aa..1d3fead 100644
--- a/test/providers/deno.skipbrowser.test.js
+++ b/test/providers/deno.skipbrowser.test.js
@@ -183,7 +183,7 @@ const oakVersion = (await lookup("denoland:oak")).resolved.version;
imports: {
fs: "https://deno.land/std@0.148.0/fs/mod.ts",
},
- }
+ },
});
await generator.link("deno:testing/asserts");
diff --git a/test/providers/esmsh-root.test.js b/test/providers/esmsh-root.test.js
index 49c995e..340935f 100644
--- a/test/providers/esmsh-root.test.js
+++ b/test/providers/esmsh-root.test.js
@@ -2,31 +2,37 @@ import { Generator } from "@jspm/generator";
import assert from "assert";
const inputMap = {
- "imports": {
- "react-intl": "https://esm.sh/*react-intl@6.4.4/lib/index.js"
+ imports: {
+ "react-intl": "https://esm.sh/*react-intl@6.4.4/lib/index.js",
},
- "scopes": {
+ scopes: {
"https://esm.sh/": {
- "@formatjs/ecma402-abstract": "https://esm.sh/*@formatjs/ecma402-abstract@1.17.0/lib/index.js",
- "@formatjs/fast-memoize": "https://esm.sh/*@formatjs/fast-memoize@2.2.0/lib/index.js",
- "@formatjs/icu-messageformat-parser": "https://esm.sh/*@formatjs/icu-messageformat-parser@2.6.0/lib/index.js",
- "@formatjs/icu-skeleton-parser": "https://esm.sh/*@formatjs/icu-skeleton-parser@1.6.0/lib/index.js",
+ "@formatjs/ecma402-abstract":
+ "https://esm.sh/*@formatjs/ecma402-abstract@1.17.0/lib/index.js",
+ "@formatjs/fast-memoize":
+ "https://esm.sh/*@formatjs/fast-memoize@2.2.0/lib/index.js",
+ "@formatjs/icu-messageformat-parser":
+ "https://esm.sh/*@formatjs/icu-messageformat-parser@2.6.0/lib/index.js",
+ "@formatjs/icu-skeleton-parser":
+ "https://esm.sh/*@formatjs/icu-skeleton-parser@1.6.0/lib/index.js",
"@formatjs/intl": "https://esm.sh/*@formatjs/intl@2.9.0/lib/index.js",
- "@formatjs/intl-localematcher": "https://esm.sh/*@formatjs/intl-localematcher@0.4.0/lib/index.js",
- "hoist-non-react-statics": "https://esm.sh/*hoist-non-react-statics@3.3.2/dist/hoist-non-react-statics.cjs.js/index.js",
- "intl-messageformat": "https://esm.sh/*intl-messageformat@10.5.0/lib/index.js",
- "react": "https://esm.sh/*react@18.2.0",
+ "@formatjs/intl-localematcher":
+ "https://esm.sh/*@formatjs/intl-localematcher@0.4.0/lib/index.js",
+ "hoist-non-react-statics":
+ "https://esm.sh/*hoist-non-react-statics@3.3.2/dist/hoist-non-react-statics.cjs.js/index.js",
+ "intl-messageformat":
+ "https://esm.sh/*intl-messageformat@10.5.0/lib/index.js",
+ react: "https://esm.sh/*react@18.2.0",
"react-is": "https://esm.sh/*react-is@16.13.1/index.js",
- "tslib": "https://esm.sh/*tslib@2.6.1"
- }
- }
+ tslib: "https://esm.sh/*tslib@2.6.1",
+ },
+ },
};
const generator = new Generator({
mapUrl: import.meta.url,
env: ["production", "browser"],
- inputMap
+ inputMap,
});
await generator.install();
-
diff --git a/test/providers/esmsh.test.js b/test/providers/esmsh.test.js
index 4cda937..05aa879 100644
--- a/test/providers/esmsh.test.js
+++ b/test/providers/esmsh.test.js
@@ -22,4 +22,4 @@ await generator.install("twind");
{
const json = generator.getMap();
assert.ok(json.imports.twind);
-}
\ No newline at end of file
+}
diff --git a/test/resolve/dayjs.test.js b/test/resolve/dayjs.test.js
index 78ba3ca..27055bd 100644
--- a/test/resolve/dayjs.test.js
+++ b/test/resolve/dayjs.test.js
@@ -2,7 +2,7 @@ import { Generator } from "@jspm/generator";
import assert from "assert";
const generator = new Generator({
- defaultProvider: 'jsdelivr'
+ defaultProvider: "jsdelivr",
});
await generator.install("@cubejs-client/core@0.35.23");
diff --git a/test/resolve/ts.test.js b/test/resolve/ts.test.js
index c7d3af9..e63c6d8 100644
--- a/test/resolve/ts.test.js
+++ b/test/resolve/ts.test.js
@@ -11,7 +11,7 @@ if (typeof document === "undefined") {
await generator.link("./tspkg/main.ts");
const map = generator.getMap();
- strictEqual(typeof map.imports['node:fs'], 'string');
+ strictEqual(typeof map.imports["node:fs"], "string");
strictEqual(
generator.getAnalysis(new URL("./tspkg/dep.ts", import.meta.url)).format,