jspm 4.0.3 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +67 -29
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2326,7 +2326,7 @@ async function writeHtmlOutput(mapFile, generator, pins, env2, flags, silent = f
|
|
|
2326
2326
|
htmlUrl: generator.mapUrl,
|
|
2327
2327
|
// URL of the output map
|
|
2328
2328
|
rootUrl: generator.rootUrl,
|
|
2329
|
-
preload: getPreloadMode(flags),
|
|
2329
|
+
preload: flags.release ? true : getPreloadMode(flags),
|
|
2330
2330
|
integrity: flags.integrity,
|
|
2331
2331
|
whitespace: !flags.compact,
|
|
2332
2332
|
comment: false
|
|
@@ -2403,8 +2403,8 @@ async function getGenerator(flags, configOverride = null, inputMap) {
|
|
|
2403
2403
|
rootUrl,
|
|
2404
2404
|
inputMap: inputMap || await getInputMap(flags),
|
|
2405
2405
|
env: await getEnv(flags),
|
|
2406
|
-
flattenScopes: flags.flattenScopes,
|
|
2407
|
-
combineSubpaths: flags.combineSubpaths,
|
|
2406
|
+
flattenScopes: flags.flattenScopes === false ? false : flags.release || flags.flattenScopes,
|
|
2407
|
+
combineSubpaths: flags.combineSubpaths === false ? false : flags.release || flags.combineSubpaths,
|
|
2408
2408
|
defaultProvider,
|
|
2409
2409
|
resolutions: getResolutions(flags),
|
|
2410
2410
|
cache: getCacheMode(flags),
|
|
@@ -2543,9 +2543,8 @@ function addEnvs(env2, newEnvs) {
|
|
|
2543
2543
|
return env2.sort();
|
|
2544
2544
|
}
|
|
2545
2545
|
async function getEnv(flags) {
|
|
2546
|
-
const inputMap = await getInputMap(flags);
|
|
2547
2546
|
const envFlags = Array.isArray(flags?.conditions) ? flags.conditions : (flags.conditions || "").split(",").map((e) => e.trim()).filter(Boolean);
|
|
2548
|
-
let env2 =
|
|
2547
|
+
let env2 = ["browser", "module", flags.release ? "production" : "development"];
|
|
2549
2548
|
env2 = removeEnvs(
|
|
2550
2549
|
env2,
|
|
2551
2550
|
envFlags.filter((env3) => env3.startsWith("no-")).map((env3) => env3.slice(3))
|
|
@@ -3382,7 +3381,7 @@ ${c6.green("Ok:")} Initialization complete.`);
|
|
|
3382
3381
|
}
|
|
3383
3382
|
}
|
|
3384
3383
|
async function initProject(flags) {
|
|
3385
|
-
const directory =
|
|
3384
|
+
const directory = process.cwd();
|
|
3386
3385
|
if (!await isDirectory(directory)) {
|
|
3387
3386
|
throw new JspmError(`Directory does not exist: ${directory}`);
|
|
3388
3387
|
}
|
|
@@ -29259,10 +29258,44 @@ async function build(flags) {
|
|
|
29259
29258
|
}
|
|
29260
29259
|
}
|
|
29261
29260
|
stopSpinner();
|
|
29261
|
+
if (flags.install !== false) {
|
|
29262
|
+
if (!flags.quiet) {
|
|
29263
|
+
console.log(`${c11.cyan("Info:")} Generating import map in build directory...`);
|
|
29264
|
+
}
|
|
29265
|
+
const map = getInputPath(flags);
|
|
29266
|
+
process.chdir(flags.out);
|
|
29267
|
+
const installFlags = {
|
|
29268
|
+
...flags,
|
|
29269
|
+
// use local map as source of truth for resolutions
|
|
29270
|
+
map,
|
|
29271
|
+
// output to default importmap.js in build dir
|
|
29272
|
+
out: getOutputPath({}),
|
|
29273
|
+
dir: void 0,
|
|
29274
|
+
release: true,
|
|
29275
|
+
quiet: true
|
|
29276
|
+
};
|
|
29277
|
+
try {
|
|
29278
|
+
await install(installFlags);
|
|
29279
|
+
if (!flags.quiet) {
|
|
29280
|
+
console.log(`${c11.green("\u2713")} Import map generated in ${c11.cyan(flags.out)}`);
|
|
29281
|
+
}
|
|
29282
|
+
} catch (error2) {
|
|
29283
|
+
if (!flags.quiet) {
|
|
29284
|
+
console.warn(`${c11.yellow("Warning:")} Failed to generate import map: ${error2.message}`);
|
|
29285
|
+
}
|
|
29286
|
+
}
|
|
29287
|
+
}
|
|
29262
29288
|
if (!flags.quiet) {
|
|
29263
|
-
|
|
29289
|
+
const infoMsg = flags.install !== false ? `${c11.green("\u2713")} Built ${c11.cyan(projectConfig.name)} to ${c11.cyan(
|
|
29290
|
+
flags.out
|
|
29291
|
+
)} with import map.` : `${c11.green("\u2713")} Built ${c11.cyan(projectConfig.name)} to ${c11.cyan(
|
|
29292
|
+
flags.out
|
|
29293
|
+
)}.
|
|
29264
29294
|
|
|
29265
|
-
${c11.cyan("Info:")} Run ${c11.bold(
|
|
29295
|
+
${c11.cyan("Info:")} Run ${c11.bold(
|
|
29296
|
+
`jspm -d ${flags.out} install --release`
|
|
29297
|
+
)} to create a production import map.`;
|
|
29298
|
+
console.log(infoMsg);
|
|
29266
29299
|
}
|
|
29267
29300
|
} catch (e) {
|
|
29268
29301
|
stopSpinner();
|
|
@@ -32328,12 +32361,12 @@ ${error2.snippet}`
|
|
|
32328
32361
|
file: relativePath2,
|
|
32329
32362
|
name: `Bare module specifier import ${c15.bold(
|
|
32330
32363
|
c15.cyan(`'${module}'`)
|
|
32331
|
-
)} is not mapped by the import map
|
|
32364
|
+
)} is not mapped by the import map. Either update the package.json "name" or update the HTML to use an import of "jspm" or "jspm/...".`,
|
|
32332
32365
|
description: `Only bare specifiers matching the project name ${c15.cyan(
|
|
32333
32366
|
c15.bold(`'${projectConfig.name}'`)
|
|
32334
32367
|
)} are mapped.`,
|
|
32335
32368
|
code: {
|
|
32336
|
-
title: "
|
|
32369
|
+
title: "Correct JSPM HTML Script:",
|
|
32337
32370
|
snippet: `<script type="module">import '${projectConfig.name}';</script>`
|
|
32338
32371
|
}
|
|
32339
32372
|
});
|
|
@@ -32767,31 +32800,33 @@ ${c16.yellow("...")}${c16.bold(remainingCount)} more ${remainingCount === 1 ? "i
|
|
|
32767
32800
|
init_init();
|
|
32768
32801
|
var { version: version2 } = JSON.parse(readFileSync3(new URL("../package.json", import.meta.url), "utf8"));
|
|
32769
32802
|
var cli = dist_default(c17.yellow("jspm"));
|
|
32770
|
-
var generateOpts = (cac2,
|
|
32803
|
+
var generateOpts = (cac2, release = false) => cac2.option(
|
|
32771
32804
|
"-m, --map <file>",
|
|
32772
32805
|
"File containing initial import map (defaults to importmap.json, supports .js with a JSON import map embedded, or HTML with an inline import map)",
|
|
32773
32806
|
{}
|
|
32774
32807
|
).option("-C, --conditions <environments>", "Comma-separated environment condition overrides", {
|
|
32775
|
-
default:
|
|
32808
|
+
default: []
|
|
32776
32809
|
}).option("-r, --resolution <resolutions>", "Comma-separated dependency resolution overrides", {}).option(
|
|
32777
32810
|
"-p, --provider <provider>",
|
|
32778
32811
|
`Default module provider. Available providers: ${availableProviders.join(", ")}`,
|
|
32779
32812
|
{}
|
|
32780
32813
|
).option("--cache <mode>", "Cache mode for fetches (online, offline, no-cache)", {
|
|
32781
32814
|
default: "online"
|
|
32782
|
-
})
|
|
32783
|
-
|
|
32784
|
-
"-
|
|
32785
|
-
"Flatten import map scopes into smaller single top-level scope per origin",
|
|
32815
|
+
}).option(
|
|
32816
|
+
"--release",
|
|
32817
|
+
"Enable release mode (--flatten-scopes, --combine-subpaths, --C=production)",
|
|
32786
32818
|
{
|
|
32787
|
-
default:
|
|
32819
|
+
default: release
|
|
32788
32820
|
}
|
|
32821
|
+
);
|
|
32822
|
+
var outputOpts = (cac2) => cac2.option("--integrity", "Add module integrity attributes to the import map", {}).option("--preload [mode]", "Add module preloads to HTML output (default: static, dynamic)", {}).option("--root <url>", "URL to treat as server root, i.e. rebase import maps against", {}).option(
|
|
32823
|
+
"-f, --flatten-scopes",
|
|
32824
|
+
"Flatten import map scopes into smaller single top-level scope per origin",
|
|
32825
|
+
{}
|
|
32789
32826
|
).option(
|
|
32790
32827
|
"-s, --combine-subpaths",
|
|
32791
32828
|
"Combine import map subpaths under folder maps (ending in /)",
|
|
32792
|
-
{
|
|
32793
|
-
default: production
|
|
32794
|
-
}
|
|
32829
|
+
{}
|
|
32795
32830
|
).option("-c, --compact", "Output a compact import map", { default: false }).option("--stdout", "Output the import map to stdout", { default: false }).option(
|
|
32796
32831
|
"-o, --out <file>",
|
|
32797
32832
|
"File to inject the final import map into (default: --map / importmap.js). For JS files outputs an injection wrapper script, for JSON files, the import map only, and for HTML files embeds the import map.",
|
|
@@ -32999,7 +33034,7 @@ Start a server that uses importmap.json as the import map.
|
|
|
32999
33034
|
`
|
|
33000
33035
|
).example(
|
|
33001
33036
|
(name) => `
|
|
33002
|
-
$ ${name} serve --
|
|
33037
|
+
$ ${name} serve --static
|
|
33003
33038
|
|
|
33004
33039
|
Start a server that does not generate the import map on startup, perform type stripping or provide a hot reload watcher
|
|
33005
33040
|
`
|
|
@@ -33033,12 +33068,16 @@ the same options as the 'jspm install' command with no arguments.
|
|
|
33033
33068
|
`
|
|
33034
33069
|
).action(wrapCommand(serve));
|
|
33035
33070
|
generateOpts(
|
|
33036
|
-
|
|
33037
|
-
|
|
33038
|
-
|
|
33039
|
-
|
|
33040
|
-
|
|
33041
|
-
|
|
33071
|
+
outputOpts(
|
|
33072
|
+
cli.command("build", "Build package").option("--no-minify", "Disable build minification", {
|
|
33073
|
+
default: true
|
|
33074
|
+
}).option("-o, --out <dir>", "Path to the output directory for the build", {
|
|
33075
|
+
default: "dist"
|
|
33076
|
+
}).option("--install", "Generate import map after build completes", {
|
|
33077
|
+
default: true
|
|
33078
|
+
}),
|
|
33079
|
+
true
|
|
33080
|
+
)
|
|
33042
33081
|
).example(
|
|
33043
33082
|
(name) => `
|
|
33044
33083
|
$ ${name} build
|
|
@@ -33106,8 +33145,7 @@ outputOpts(
|
|
|
33106
33145
|
{}
|
|
33107
33146
|
).option("--eject <package>", "Eject a published package instead of publishing", {}),
|
|
33108
33147
|
true
|
|
33109
|
-
)
|
|
33110
|
-
true
|
|
33148
|
+
)
|
|
33111
33149
|
).example(
|
|
33112
33150
|
(name) => `
|
|
33113
33151
|
$ ${name} publish
|