jspm 3.0.0 → 3.0.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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/dist/cli.js +39 -14
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  <img style="display: inline-block; width: 100px; vertical-align: middle; margin-top: -1em;" src="https://jspm.org/jspm.png"/>
3
3
  <h1 style="display: inline-block">JSPM CLI</h1>
4
4
  <p><strong>JSPM CLI is the package management of the JSPM project, supporting import map package management.</strong></p>
5
- <a href="https://jspm.org/getting-started">Getting Started</a> | <a href="https://jspm.org/docs/jspm">Documentation</a> | <a href="https://jspm.org/faq">FAQ</a>
5
+ <a href="https://jspm.org/getting-started">Getting Started</a> | <a href="https://jspm.org/docs/jspm-cli">Documentation</a> | <a href="https://jspm.org/faq">FAQ</a>
6
6
  <br />
7
7
  <hr style="width:50%"/>
8
8
  </div>
@@ -15,7 +15,7 @@
15
15
  * Support for a wide range of CDNs, such as `jspm.io`, `jsDeliver`, `esm.sh` and `unpkg`.
16
16
  * Import map extraction/injection into HTML files, with module preloading and integrity attributes.
17
17
 
18
- See the [documentation](https://jspm.org/docs/jspm) and [getting started](https://jspm.org/docs/getting-started) guide on jspm.org.
18
+ See the [documentation](https://jspm.org/docs/jspm-cli) and [getting started](https://jspm.org/docs/getting-started) guide on jspm.org.
19
19
 
20
20
  ## Contributing
21
21
 
package/dist/cli.js CHANGED
@@ -593,7 +593,7 @@ var cac = (name = "") => new CAC(name);
593
593
  var dist_default = cac;
594
594
 
595
595
  // package.json
596
- var version = "3.0.0";
596
+ var version = "3.0.1";
597
597
 
598
598
  // src/clearCache.ts
599
599
  import c from "picocolors";
@@ -759,7 +759,7 @@ async function writeHtmlOutput(mapFile, generator, pins, env, flags, silent = fa
759
759
  htmlUrl: generator.mapUrl,
760
760
  // URL of the output map
761
761
  rootUrl: generator.rootUrl,
762
- preload: flags.preload,
762
+ preload: getPreloadMode(flags),
763
763
  integrity: flags.integrity,
764
764
  whitespace: !flags.compact,
765
765
  comment: false
@@ -953,10 +953,10 @@ function getCacheMode(flags) {
953
953
  )} Use a locally cached module if available and fresh.
954
954
  ${c3.bold(
955
955
  "offline"
956
- )} Use a locally cached module if available, even if stale.
956
+ )} Use a locally cached module if available, even if stale.
957
957
  ${c3.bold(
958
958
  "no-cache"
959
- )} Never use the local cache.`
959
+ )} Never use the local cache.`
960
960
  );
961
961
  if (flags.cache === "offline")
962
962
  return "offline";
@@ -964,6 +964,29 @@ function getCacheMode(flags) {
964
964
  return true;
965
965
  return false;
966
966
  }
967
+ var validPreloadModes = ["static", "dynamic"];
968
+ function getPreloadMode(flags) {
969
+ if (flags.preload === null || flags.preload === void 0)
970
+ return false;
971
+ if (typeof flags.preload === "boolean") {
972
+ return flags.preload;
973
+ }
974
+ if (!validPreloadModes.includes(flags.preload))
975
+ throw new JspmError(
976
+ `Invalid preload mode "${flags.preload}". Available modes are: "${validPreloadModes.join('", "')}" (default).
977
+ ${c3.bold(
978
+ "static"
979
+ )} Inject preload tags for static dependencies.
980
+ ${c3.bold(
981
+ "dynamic"
982
+ )} Inject preload tags for static and dynamic dependencies.`
983
+ );
984
+ if (flags.preload === "static")
985
+ return "static";
986
+ if (flags.preload === "dynamic")
987
+ return "all";
988
+ return false;
989
+ }
967
990
  var spinner = ora({ spinner: "dots" });
968
991
  function startSpinner(text) {
969
992
  spinner.start(text);
@@ -1035,7 +1058,9 @@ async function install(packages, flags) {
1035
1058
  const imports = {};
1036
1059
  for (const { alias, target } of urlLikePackages) {
1037
1060
  if (!alias)
1038
- throw new JspmError(`URL-like target "${target}" must be given an alias to install under, such as "name=${target}".`);
1061
+ throw new JspmError(
1062
+ `URL-like target "${target}" must be given an alias to install under, such as "name=${target}".`
1063
+ );
1039
1064
  imports[alias] = target;
1040
1065
  }
1041
1066
  pins.push(...await generator.addMappings(JSON.stringify({ imports })));
@@ -1259,9 +1284,9 @@ var outputOpt = [
1259
1284
  {}
1260
1285
  ];
1261
1286
  var preloadOpt = [
1262
- "--preload",
1263
- "Add module preloads to HTML output",
1264
- { default: false }
1287
+ "--preload [mode]",
1288
+ "Add module preloads to HTML output (default: static, dynamic)",
1289
+ {}
1265
1290
  ];
1266
1291
  var integrityOpt = [
1267
1292
  "--integrity",
@@ -1295,7 +1320,7 @@ Run "jspm" without any arguments to see the help file.`
1295
1320
  );
1296
1321
  })
1297
1322
  );
1298
- cli.command("link [...modules]", "link modules").alias("trace").option(...mapOpt).option(...outputOpt).option(...envOpt).option(...resolutionOpt).option(...providerOpt).option(...cacheOpt).option(...rootOpt).option(...integrityOpt).option(...preloadOpt).option(...compactOpt).option(...freezeOpt).option(...stdoutOpt).example(
1323
+ cli.command("link [...modules]", "link modules").alias("trace").option(...mapOpt).option(...outputOpt).option(...envOpt).option(...resolutionOpt).option(...providerOpt).option(...cacheOpt).option(...rootOpt).option(...preloadOpt).option(...integrityOpt).option(...compactOpt).option(...freezeOpt).option(...stdoutOpt).example(
1299
1324
  (name) => `Link a remote package in importmap.json
1300
1325
  $ ${name} link chalk@5.2.0
1301
1326
  `
@@ -1305,7 +1330,7 @@ cli.command("link [...modules]", "link modules").alias("trace").option(...mapOpt
1305
1330
  `
1306
1331
  ).example(
1307
1332
  (name) => `Link an HTML file and update its import map including preload and integrity tags
1308
- $ ${name} link --map index.html --integrity --preload
1333
+ $ ${name} link --map index.html --integrity --preload dynamic
1309
1334
  `
1310
1335
  ).usage(
1311
1336
  `link [flags] [...modules]
@@ -1320,7 +1345,7 @@ In some cases there may be ambiguity. For instance, you may want to link the NPM
1320
1345
 
1321
1346
  If no modules are given, all "imports" in the initial map are relinked.`
1322
1347
  ).action(wrapCommand(link));
1323
- cli.command("install [...packages]", "install packages").alias("i").option(...mapOpt).option(...outputOpt).option(...envOpt).option(...resolutionOpt).option(...providerOpt).option(...cacheOpt).option(...rootOpt).option(...integrityOpt).option(...preloadOpt).option(...compactOpt).option(...freezeOpt).option(...stdoutOpt).example(
1348
+ cli.command("install [...packages]", "install packages").alias("i").option(...mapOpt).option(...outputOpt).option(...envOpt).option(...resolutionOpt).option(...providerOpt).option(...cacheOpt).option(...rootOpt).option(...preloadOpt).option(...integrityOpt).option(...compactOpt).option(...freezeOpt).option(...stdoutOpt).example(
1324
1349
  (name) => `Install a package
1325
1350
  $ ${name} install lit
1326
1351
  `
@@ -1341,13 +1366,13 @@ cli.command("install [...packages]", "install packages").alias("i").option(...ma
1341
1366
  $ ${name} install alias=react
1342
1367
  `
1343
1368
  ).usage(
1344
- `link [flags] [...packages]
1369
+ `install [flags] [...packages]
1345
1370
 
1346
1371
  Installs packages into an import map, along with all of the dependencies that are necessary to import them.By default, the latest versions of the packages that are compatible with the local "package.json" are installed, unless an explicit version is specified. The given packages must be valid package specifiers, such as \`npm:react@18.0.0\` or \`denoland:oak\`. If a package specifier with no registry is given, such as \`lit\`, the registry is assumed to be NPM. Packages can be installed under an alias by using specifiers such as \`myname=npm:lit@2.1.0\`. An optional subpath can be provided, such as \`npm:lit@2.2.0/decorators.js\`, in which case only the dependencies for that subpath are installed.
1347
1372
 
1348
1373
  If no packages are provided, all "imports" in the initial map are reinstalled.`
1349
1374
  ).action(wrapCommand(install));
1350
- cli.command("uninstall [...packages]", "remove packages").option(...mapOpt).option(...outputOpt).option(...envOpt).option(...resolutionOpt).option(...providerOpt).option(...cacheOpt).option(...rootOpt).option(...integrityOpt).option(...preloadOpt).option(...compactOpt).option(...freezeOpt).option(...stdoutOpt).example(
1375
+ cli.command("uninstall [...packages]", "remove packages").option(...mapOpt).option(...outputOpt).option(...envOpt).option(...resolutionOpt).option(...providerOpt).option(...cacheOpt).option(...rootOpt).option(...preloadOpt).option(...integrityOpt).option(...compactOpt).option(...freezeOpt).option(...stdoutOpt).example(
1351
1376
  (name) => `
1352
1377
  $ ${name} uninstall lit lodash
1353
1378
 
@@ -1358,7 +1383,7 @@ Uninstall "lit" and "lodash" from importmap.json.
1358
1383
 
1359
1384
  Uninstalls packages from an import map. The given packages must be valid package specifiers, such as \`npm:react@18.0.0\`, \`denoland:oak\` or \`lit\`, and must be present in the initial import map.`
1360
1385
  ).action(wrapCommand(uninstall));
1361
- cli.command("update [...packages]", "update packages").alias("upgrade").option(...mapOpt).option(...outputOpt).option(...envOpt).option(...resolutionOpt).option(...providerOpt).option(...cacheOpt).option(...rootOpt).option(...integrityOpt).option(...preloadOpt).option(...compactOpt).option(...freezeOpt).option(...stdoutOpt).example(
1386
+ cli.command("update [...packages]", "update packages").alias("upgrade").option(...mapOpt).option(...outputOpt).option(...envOpt).option(...resolutionOpt).option(...providerOpt).option(...cacheOpt).option(...rootOpt).option(...preloadOpt).option(...integrityOpt).option(...compactOpt).option(...freezeOpt).option(...stdoutOpt).example(
1362
1387
  (name) => `
1363
1388
  $ ${name} update react-dom
1364
1389
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jspm",
3
3
  "type": "module",
4
- "version": "3.0.0",
4
+ "version": "3.0.1",
5
5
  "description": "Import Map Package Manager",
6
6
  "license": "Apache-2.0",
7
7
  "bin": {
@@ -12,7 +12,7 @@
12
12
  "jspm.js"
13
13
  ],
14
14
  "dependencies": {
15
- "@jspm/generator": "^1.1.6",
15
+ "@jspm/generator": "^1.1.9",
16
16
  "cac": "^6.7.14",
17
17
  "ora": "^6.3.0",
18
18
  "picocolors": "^1.0.0"
@@ -22,7 +22,7 @@
22
22
  "@babel/core": "^7.21.4",
23
23
  "@types/node": "^18.15.11",
24
24
  "esbuild": "^0.16.17",
25
- "eslint": "^8.37.0",
25
+ "eslint": "^8.38.0",
26
26
  "eslint-config-prettier": "^8.8.0",
27
27
  "prettier": "^2.8.7",
28
28
  "tinyspy": "^1.1.1",