jspm 3.3.1 → 3.3.2

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 (2) hide show
  1. package/dist/cli.js +41 -32
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ var __esm = (fn, res) => function __init() {
4
4
  };
5
5
 
6
6
  // node_modules/rollup/dist/es/shared/node-entry.js
7
- import { resolve, basename, extname, dirname, relative as relative$1 } from "node:path";
7
+ import { resolve, basename, extname as extname2, dirname, relative as relative$1 } from "node:path";
8
8
  import require$$0$1, { win32, posix, isAbsolute as isAbsolute$1, resolve as resolve$1 } from "path";
9
9
  import process$1, { env as env$1 } from "node:process";
10
10
  import { performance } from "node:perf_hooks";
@@ -243,7 +243,7 @@ function normalize(path4) {
243
243
  }
244
244
  function getAliasName(id) {
245
245
  const base2 = basename(id);
246
- return base2.slice(0, Math.max(0, base2.length - extname(id).length));
246
+ return base2.slice(0, Math.max(0, base2.length - extname2(id).length));
247
247
  }
248
248
  function relativeId(id) {
249
249
  if (!isAbsolute(id))
@@ -701,7 +701,7 @@ function logInvalidFormatForTopLevelAwait(id, format) {
701
701
  };
702
702
  }
703
703
  function logMissingExport(binding, importingModule, exporter) {
704
- const isJson = extname(exporter) === ".json";
704
+ const isJson = extname2(exporter) === ".json";
705
705
  return {
706
706
  binding,
707
707
  code: MISSING_EXPORT,
@@ -2671,7 +2671,7 @@ function renderNamePattern(pattern, patternName, replacements) {
2671
2671
  function makeUnique(name, { [lowercaseBundleKeys]: reservedLowercaseBundleKeys }) {
2672
2672
  if (!reservedLowercaseBundleKeys.has(name.toLowerCase()))
2673
2673
  return name;
2674
- const extension = extname(name);
2674
+ const extension = extname2(name);
2675
2675
  name = name.slice(0, Math.max(0, name.length - extension.length));
2676
2676
  let uniqueName, uniqueIndex = 1;
2677
2677
  while (reservedLowercaseBundleKeys.has((uniqueName = name + ++uniqueIndex + extension).toLowerCase()))
@@ -4100,10 +4100,10 @@ function getSourceHash(source) {
4100
4100
  function generateAssetFileName(name, source, sourceHash, outputOptions, bundle) {
4101
4101
  const emittedName = outputOptions.sanitizeFileName(name || "asset");
4102
4102
  return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === "function" ? outputOptions.assetFileNames({ name, source, type: "asset" }) : outputOptions.assetFileNames, "output.assetFileNames", {
4103
- ext: () => extname(emittedName).slice(1),
4104
- extname: () => extname(emittedName),
4103
+ ext: () => extname2(emittedName).slice(1),
4104
+ extname: () => extname2(emittedName),
4105
4105
  hash: (size) => sourceHash.slice(0, Math.max(0, size || defaultHashSize)),
4106
- name: () => emittedName.slice(0, Math.max(0, emittedName.length - extname(emittedName).length))
4106
+ name: () => emittedName.slice(0, Math.max(0, emittedName.length - extname2(emittedName).length))
4107
4107
  }), bundle);
4108
4108
  }
4109
4109
  function reserveFileNameInBundle(fileName, { bundle }, log2) {
@@ -15052,7 +15052,7 @@ var init_node_entry = __esm({
15052
15052
  }
15053
15053
  basename() {
15054
15054
  const base2 = basename(this.id);
15055
- const extension = extname(this.id);
15055
+ const extension = extname2(this.id);
15056
15056
  return makeLegal(extension ? base2.slice(0, -extension.length) : base2);
15057
15057
  }
15058
15058
  bindReferences() {
@@ -16565,7 +16565,7 @@ ${next}` : out;
16565
16565
  return predefinedChunkName;
16566
16566
  const { preserveModulesRoot, sanitizeFileName: sanitizeFileName2 } = this.outputOptions;
16567
16567
  const sanitizedId = sanitizeFileName2(normalize(module.id.split(QUERY_HASH_REGEX, 1)[0]));
16568
- const extensionName = extname(sanitizedId);
16568
+ const extensionName = extname2(sanitizedId);
16569
16569
  const idWithoutExtension = NON_ASSET_EXTENSIONS.has(extensionName) ? sanitizedId.slice(0, -extensionName.length) : sanitizedId;
16570
16570
  if (isAbsolute(idWithoutExtension)) {
16571
16571
  return preserveModulesRoot && resolve(idWithoutExtension).startsWith(preserveModulesRoot) ? idWithoutExtension.slice(preserveModulesRoot.length).replace(/^[/\\]/, "") : relative(this.inputBase, idWithoutExtension);
@@ -24334,7 +24334,7 @@ var cac = (name = "") => new CAC(name);
24334
24334
  var dist_default = cac;
24335
24335
 
24336
24336
  // package.json
24337
- var version = "3.3.1";
24337
+ var version = "3.3.2";
24338
24338
 
24339
24339
  // src/clearCache.ts
24340
24340
  import c from "picocolors";
@@ -24414,12 +24414,16 @@ function createLogger() {
24414
24414
 
24415
24415
  // src/utils.ts
24416
24416
  import fs2 from "node:fs/promises";
24417
+ import { accessSync } from "node:fs";
24417
24418
  import path from "node:path";
24418
24419
  import { pathToFileURL } from "node:url";
24419
24420
  import { Generator, analyzeHtml } from "@jspm/generator";
24420
24421
  import ora from "ora";
24421
24422
  import c3 from "picocolors";
24422
- var defaultInputPath = "./importmap.json";
24423
+ var defaultMapPath = "importmap.json";
24424
+ function isJsExtension(ext) {
24425
+ return ext === ".js" || ext === ".mjs" || ext === ".cjs" || ext === ".ts" || ext === ".mts" || ext === ".cts" || ext === ".jsx" || ext === ".tsx";
24426
+ }
24423
24427
  var defaultHtmlTemplate = `<!DOCTYPE html>
24424
24428
  <html>
24425
24429
  <head>
@@ -24479,7 +24483,7 @@ async function writeHtmlOutput(mapFile, generator, pins, env2, flags, silent = f
24479
24483
  `JSPM does not have permission to write to ${mapFile}.`
24480
24484
  );
24481
24485
  const mapFileRel = path.relative(process.cwd(), mapFile);
24482
- if (!await exists(mapFile)) {
24486
+ if (!exists(mapFile)) {
24483
24487
  !silent && console.warn(
24484
24488
  `${c3.cyan(
24485
24489
  "Note:"
@@ -24562,12 +24566,12 @@ async function getGenerator(flags, setEnv = true) {
24562
24566
  // TODO: only for --local flag
24563
24567
  });
24564
24568
  }
24565
- async function getInput(flags) {
24566
- const mapFile = getInputPath(flags);
24567
- if (!await exists(mapFile))
24569
+ async function getInput(flags, fallbackDefaultMap = defaultMapPath) {
24570
+ const mapFile = getInputPath(flags, fallbackDefaultMap);
24571
+ if (!exists(mapFile))
24568
24572
  return void 0;
24569
- if (!await canRead(mapFile)) {
24570
- if (mapFile === defaultInputPath)
24573
+ if (!canRead(mapFile)) {
24574
+ if (mapFile === defaultMapPath)
24571
24575
  return void 0;
24572
24576
  else
24573
24577
  throw new JspmError(`JSPM does not have permission to read ${mapFile}.`);
@@ -24596,13 +24600,16 @@ async function getInputMap(flags) {
24596
24600
  }
24597
24601
  return inputMap || {};
24598
24602
  }
24599
- function getInputPath(flags) {
24600
- return path.resolve(process.cwd(), flags?.map || defaultInputPath);
24603
+ function getInputPath(flags, fallbackDefaultMap = defaultMapPath) {
24604
+ return path.resolve(
24605
+ process.cwd(),
24606
+ flags?.map || (exists(defaultMapPath) ? defaultMapPath : fallbackDefaultMap)
24607
+ );
24601
24608
  }
24602
24609
  function getOutputPath(flags) {
24603
24610
  return path.resolve(
24604
24611
  process.cwd(),
24605
- flags.output || flags.map || defaultInputPath
24612
+ flags.output || flags.map || defaultMapPath
24606
24613
  );
24607
24614
  }
24608
24615
  function getOutputMapUrl(flags) {
@@ -24740,27 +24747,27 @@ function startSpinner(text) {
24740
24747
  function stopSpinner() {
24741
24748
  spinner.stop();
24742
24749
  }
24743
- async function exists(file) {
24750
+ function exists(file) {
24744
24751
  try {
24745
- await fs2.access(file);
24752
+ accessSync(file);
24746
24753
  return true;
24747
24754
  } catch (e) {
24748
24755
  return false;
24749
24756
  }
24750
24757
  }
24751
- async function canRead(file) {
24758
+ function canRead(file) {
24752
24759
  try {
24753
- await fs2.access(file, (fs2.constants || fs2).R_OK);
24760
+ accessSync(file, (fs2.constants || fs2).R_OK);
24754
24761
  return true;
24755
24762
  } catch (e) {
24756
24763
  return false;
24757
24764
  }
24758
24765
  }
24759
- async function canWrite(file) {
24766
+ function canWrite(file) {
24760
24767
  try {
24761
- if (!await exists(file))
24768
+ if (!exists(file))
24762
24769
  return true;
24763
- await fs2.access(file, (fs2.constants || fs2).W_OK);
24770
+ accessSync(file, (fs2.constants || fs2).W_OK);
24764
24771
  return true;
24765
24772
  } catch (e) {
24766
24773
  return false;
@@ -24836,21 +24843,23 @@ async function install(packages, flags) {
24836
24843
 
24837
24844
  // src/link.ts
24838
24845
  import * as fs3 from "node:fs/promises";
24846
+ import { extname } from "node:path";
24839
24847
  import { pathToFileURL as pathToFileURL2 } from "url";
24840
24848
  import c5 from "picocolors";
24841
24849
  async function link(modules, flags) {
24842
24850
  const log2 = withType("link/link");
24843
24851
  log2(`Linking modules: ${modules.join(", ")}`);
24844
24852
  log2(`Flags: ${JSON.stringify(flags)}`);
24853
+ const fallbackMap = !modules[0] || isJsExtension(extname(modules[0])) ? void 0 : modules[0];
24845
24854
  const env2 = await getEnv(flags);
24846
- const inputMapPath = getInputPath(flags);
24855
+ const inputMapPath = getInputPath(flags, fallbackMap);
24847
24856
  const outputMapPath = getOutputPath(flags);
24848
24857
  const generator = await getGenerator(flags);
24849
24858
  const inlinePins = [];
24850
24859
  const resolvedModules = (await Promise.all(
24851
24860
  modules.map((spec) => resolveModule(spec, inlinePins, generator))
24852
24861
  )).filter((m) => !!m);
24853
- const input = await getInput(flags);
24862
+ const input = await getInput(flags, fallbackMap);
24854
24863
  const pins = inlinePins.concat(resolvedModules.map((p) => p.target));
24855
24864
  let allPins = pins;
24856
24865
  if (input) {
@@ -25106,8 +25115,8 @@ async function build(entry, options) {
25106
25115
  var cli = dist_default(c8.yellow("jspm"));
25107
25116
  var mapOpt = [
25108
25117
  "-m, --map <file>",
25109
- "File containing initial import map",
25110
- { default: "importmap.json" }
25118
+ "File containing initial import map (defaults to importmap.json, or the input HTML if linking)",
25119
+ {}
25111
25120
  ];
25112
25121
  var envOpt = [
25113
25122
  "-e, --env <environments>",
@@ -25193,7 +25202,7 @@ cli.command("link [...modules]", "link modules").alias("trace").option(...mapOpt
25193
25202
  `
25194
25203
  ).example(
25195
25204
  (name) => `Link an HTML file and update its import map including preload and integrity tags
25196
- $ ${name} link --map index.html --integrity --preload dynamic
25205
+ $ ${name} link --map index.html --integrity --preload
25197
25206
  `
25198
25207
  ).usage(
25199
25208
  `link [flags] [...modules]
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jspm",
3
3
  "type": "module",
4
- "version": "3.3.1",
4
+ "version": "3.3.2",
5
5
  "description": "Import Map Package Manager",
6
6
  "license": "Apache-2.0",
7
7
  "bin": {