jspm 4.0.1 → 4.0.3

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 +85 -59
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -2494,19 +2494,23 @@ function getInputPath(flags, fallbackDefaultMap = defaultMapPath) {
2494
2494
  if (mapPath) {
2495
2495
  return resolve(mapPath);
2496
2496
  }
2497
- if (exists(defaultMapPath)) {
2498
- return resolve(defaultMapPath);
2497
+ const defaultMapPathResolved = resolve(flags.dir ?? ".", defaultMapPath);
2498
+ if (exists(defaultMapPathResolved)) {
2499
+ return defaultMapPathResolved;
2499
2500
  }
2500
- return resolve(fallbackDefaultMap);
2501
+ const fallbackDefaultMapResolved = resolve(flags.dir ?? ".", fallbackDefaultMap);
2502
+ return fallbackDefaultMapResolved;
2501
2503
  }
2502
2504
  function getOutputPath(flags) {
2503
2505
  if (flags.out || flags.map) {
2504
2506
  return resolve(flags.out || flags.map);
2505
2507
  }
2506
- if (exists(defaultMapPath)) {
2507
- return resolve(defaultMapPath);
2508
+ const defaultMapPathResolved = resolve(flags.dir ?? ".", defaultMapPath);
2509
+ if (defaultMapPathResolved) {
2510
+ return defaultMapPathResolved;
2508
2511
  }
2509
- return resolve(defaultMapPath);
2512
+ const fallbackDefaultMapResolved = resolve(flags.dir ?? ".", defaultMapPath);
2513
+ return fallbackDefaultMapResolved;
2510
2514
  }
2511
2515
  function getOutputMapUrl(flags) {
2512
2516
  return pathToFileURL(getOutputPath(flags));
@@ -29205,7 +29209,7 @@ async function build(flags) {
29205
29209
  format: "esm",
29206
29210
  assetFileNames: "[name][extname]",
29207
29211
  entryFileNames: "[name]",
29208
- chunkFileNames: "[name]",
29212
+ chunkFileNames: "lib/[name]-[hash:8].js",
29209
29213
  sourcemap: true,
29210
29214
  compact: flags.minify
29211
29215
  });
@@ -29219,7 +29223,18 @@ async function build(flags) {
29219
29223
  await writeFile3(`${outPath}.map`, JSON.stringify(chunk.map));
29220
29224
  }
29221
29225
  }
29222
- const generatedFiles = new Set(output.map((chunk) => chunk.fileName));
29226
+ const projectBase = `${pathToFileURL4(projectConfig.projectPath).href}/`;
29227
+ const generatedFiles = /* @__PURE__ */ new Set();
29228
+ for (const chunk of output) {
29229
+ generatedFiles.add(chunk.fileName);
29230
+ if (chunk.type === "chunk") {
29231
+ for (const refFile of chunk.moduleIds) {
29232
+ if (refFile.startsWith(projectBase)) {
29233
+ generatedFiles.add(relative3(projectBase, refFile).replace(/\\/g, "/"));
29234
+ }
29235
+ }
29236
+ }
29237
+ }
29223
29238
  {
29224
29239
  const pjson = JSON.parse(
29225
29240
  readFileSync2(join3(projectConfig.projectPath, "package.json"), "utf8")
@@ -29245,7 +29260,9 @@ async function build(flags) {
29245
29260
  }
29246
29261
  stopSpinner();
29247
29262
  if (!flags.quiet) {
29248
- console.log(`${c11.green("\u2713")} Built ${c11.cyan(projectConfig.name)} to ${c11.cyan(flags.out)}`);
29263
+ console.log(`${c11.green("\u2713")} Built ${c11.cyan(projectConfig.name)} to ${c11.cyan(flags.out)}.
29264
+
29265
+ ${c11.cyan("Info:")} Run ${c11.bold("jspm -d dist install -C production -fs")} to create a production build map.`);
29249
29266
  }
29250
29267
  } catch (e) {
29251
29268
  stopSpinner();
@@ -29299,7 +29316,7 @@ function cssPlugin({ minify, baseUrl }) {
29299
29316
  };
29300
29317
  }
29301
29318
 
29302
- // src/deploy.ts
29319
+ // src/publish.ts
29303
29320
  import fs8 from "node:fs/promises";
29304
29321
  import path6 from "node:path";
29305
29322
  import { pathToFileURL as pathToFileURL5 } from "node:url";
@@ -29774,7 +29791,7 @@ defineLazyProperty(apps, "browser", () => "browser");
29774
29791
  defineLazyProperty(apps, "browserPrivate", () => "browserPrivate");
29775
29792
  var open_default = open;
29776
29793
 
29777
- // src/deploy.ts
29794
+ // src/publish.ts
29778
29795
  init_utils();
29779
29796
  init_logger();
29780
29797
  init_config();
@@ -29790,7 +29807,7 @@ function showShortcuts(directory) {
29790
29807
  \u2192 ${c12.bold(c12.bgBlueBright(c12.whiteBright(" p ")))} ${c12.dim(
29791
29808
  "Open self-contained preview URL in the browser"
29792
29809
  )}
29793
- \u2192 ${c12.bold(c12.bgBlueBright(c12.whiteBright(" r ")))} ${c12.dim("Force redeployment")}
29810
+ \u2192 ${c12.bold(c12.bgBlueBright(c12.whiteBright(" r ")))} ${c12.dim("Force republish")}
29794
29811
  \u2192 ${c12.bold(c12.bgBlueBright(c12.whiteBright(" q ")))} ${c12.dim("Stop (or Ctrl+C)")}`);
29795
29812
  console.log(`${c12.blue("Info:")} Watching for changes in ${c12.cyan(directory)}...`);
29796
29813
  process.stdin.setRawMode?.(true);
@@ -29812,18 +29829,16 @@ async function readJsonFile(filePath, defaultValue = {}) {
29812
29829
  return defaultValue;
29813
29830
  }
29814
29831
  async function eject(flags) {
29815
- const log2 = withType("deploy/eject");
29832
+ const log2 = withType("publish/eject");
29816
29833
  const pkg = flags.eject;
29817
29834
  if (!pkg.startsWith("app:")) {
29818
- throw new JspmError(
29819
- `Only the app: JSPM deployment registry is currently supported for ejection.`
29820
- );
29835
+ throw new JspmError(`Only the app: JSPM registry is currently supported for ejection.`);
29821
29836
  }
29822
29837
  const config = await loadConfig();
29823
29838
  log2(
29824
29839
  `Loaded config with ${config.providers ? Object.keys(config.providers).length : 0} provider configurations`
29825
29840
  );
29826
- const provider2 = flags.provider || config.defaultDeployProvider || "jspm.io";
29841
+ const provider2 = flags.provider || config.defaultPublishProvider || "jspm.io";
29827
29842
  const generator = await getGenerator(flags);
29828
29843
  let name = pkg.slice(4);
29829
29844
  if (name[0] !== "@")
@@ -29836,14 +29851,14 @@ async function eject(flags) {
29836
29851
  startSpinner(`Ejecting ${c12.bold(pkg)}...`);
29837
29852
  await generator.eject({ name, version: version3, provider: provider2 }, ".");
29838
29853
  stopSpinner();
29839
- startSpinner(`Merging deployment import map for ${c12.bold(pkg)}...`);
29854
+ startSpinner(`Merging published import map for ${c12.bold(pkg)}...`);
29840
29855
  const env2 = await getEnv(flags);
29841
29856
  await writeOutput(generator, null, env2, flags, flags.quiet);
29842
29857
  stopSpinner();
29843
29858
  console.log(`${c12.green("Ok:")} Package ${c12.green(pkg)} ejected into ${c12.bold(flags.dir)}`);
29844
29859
  }
29845
29860
  async function publish(flags = {}) {
29846
- const log2 = withType("deploy/publish");
29861
+ const log2 = withType("publish/publish");
29847
29862
  const { initProject: initProject2 } = await Promise.resolve().then(() => (init_init(), init_exports));
29848
29863
  try {
29849
29864
  const projectConfig = await initProject2({
@@ -29869,7 +29884,7 @@ async function publish(flags = {}) {
29869
29884
  if (flags.watch) {
29870
29885
  if (semverVersion || !version3.match(/^[a-zA-Z0-9_\-]+$/)) {
29871
29886
  throw new JspmError(
29872
- `Invalid version "${version3}" for deploy --watch. Watched deployments must be to mutable versions, which are alphanumeric only with - or _ separators.`
29887
+ `Invalid version "${version3}" for publish --watch. Watched publishes must be to mutable versions, which are alphanumeric only with - or _ separators.`
29873
29888
  );
29874
29889
  }
29875
29890
  return startWatchMode(
@@ -29882,7 +29897,7 @@ async function publish(flags = {}) {
29882
29897
  prepareScript
29883
29898
  );
29884
29899
  }
29885
- return deployOnce(
29900
+ return publishOnce(
29886
29901
  name,
29887
29902
  version3,
29888
29903
  projectConfig.projectPath,
@@ -29897,16 +29912,16 @@ async function publish(flags = {}) {
29897
29912
  throw new JspmError(`Failed to initialize project: ${error2.message}`);
29898
29913
  }
29899
29914
  }
29900
- async function deployOnce(name, version3, directory, flags, logSnippet, prepareScript) {
29901
- const log2 = withType("deploy");
29915
+ async function publishOnce(name, version3, directory, flags, logSnippet, prepareScript) {
29916
+ const log2 = withType("publish");
29902
29917
  const config = await loadConfig();
29903
29918
  log2(
29904
29919
  `Loaded config with ${config.providers ? Object.keys(config.providers).length : 0} provider configurations`
29905
29920
  );
29906
- const deployProvider = flags.provider || config.defaultDeployProvider;
29907
- if (!deployProvider) {
29921
+ const publishProvider = flags.provider || config.defaultPublishProvider;
29922
+ if (!publishProvider) {
29908
29923
  throw new JspmError(
29909
- `No deploy provider specified. Please provide a provider with the --provider flag (e.g., jspm deploy -p jspm.io) or set a default provider in your config.`
29924
+ `No publish provider specified. Please provide a provider with the --provider flag (e.g., jspm publish -p jspm.io) or set a default provider in your config.`
29910
29925
  );
29911
29926
  }
29912
29927
  if (prepareScript) {
@@ -29914,22 +29929,22 @@ async function deployOnce(name, version3, directory, flags, logSnippet, prepareS
29914
29929
  await runPackageScript(prepareScript, directory);
29915
29930
  console.log(`${c12.blue("Info:")} ${c12.bold("prepare")} script completed`);
29916
29931
  }
29917
- startSpinner(`Deploying ${c12.bold(`${name}@${version3}`)} to ${deployProvider}...`);
29932
+ startSpinner(`Publishing ${c12.bold(`${name}@${version3}`)} to ${publishProvider}...`);
29918
29933
  const generator = await getGenerator(flags, {
29919
29934
  mapUrl: pathToFileURL5(`${directory}/`)
29920
29935
  });
29921
29936
  try {
29922
- const { packageUrl, mapUrl, codeSnippet } = await generator.deploy({
29937
+ const { packageUrl, mapUrl, codeSnippet } = await generator.publish({
29923
29938
  package: pathToFileURL5(directory).href,
29924
29939
  name,
29925
29940
  version: version3,
29926
- provider: deployProvider,
29941
+ provider: publishProvider,
29927
29942
  importMap: true,
29928
29943
  install: true
29929
29944
  });
29930
29945
  stopSpinner();
29931
29946
  console.log(
29932
- `${c12.green("Ok:")} Package deployed to ${c12.green(packageUrl)} with import map ${c12.green(
29947
+ `${c12.green("Ok:")} Package published to ${c12.green(packageUrl)} with import map ${c12.green(
29933
29948
  mapUrl
29934
29949
  )}`
29935
29950
  );
@@ -29946,14 +29961,14 @@ ${c12.greenBright(
29946
29961
  return { packageUrl, mapUrl, codeSnippet };
29947
29962
  } catch (error2) {
29948
29963
  stopSpinner();
29949
- throw new JspmError(`Failed to deploy: ${error2.message}`);
29964
+ throw new JspmError(`Failed to publish: ${error2.message}`);
29950
29965
  }
29951
29966
  }
29952
29967
  async function startWatchMode(name, version3, directory, ignore2, include, flags, prepareScript) {
29953
- let lastDeployTime = 0;
29968
+ let lastPublishTime = 0;
29954
29969
  const fileMTimes = /* @__PURE__ */ new Map();
29955
29970
  let packageUrl, codeSnippet;
29956
- let forcedRedeploy = false;
29971
+ let forcedRepublish = false;
29957
29972
  let lastRunWasError = false;
29958
29973
  let waiting = false;
29959
29974
  await watchLoop(true);
@@ -29997,7 +30012,7 @@ ${c12.blue("Info:")} Watch mode stopped`);
29997
30012
  open_default(packageUrl.endsWith("/") ? packageUrl : `${packageUrl}/`);
29998
30013
  break;
29999
30014
  case "r":
30000
- forcedRedeploy = true;
30015
+ forcedRepublish = true;
30001
30016
  break;
30002
30017
  case "c":
30003
30018
  if (codeSnippet)
@@ -30017,7 +30032,7 @@ ${codeSnippet.split("\n").filter((l) => !l.startsWith("<!--") || !l.endsWith("--
30017
30032
  });
30018
30033
  async function watchLoop(firstRun) {
30019
30034
  try {
30020
- if (Date.now() - lastDeployTime < 2e3) {
30035
+ if (Date.now() - lastPublishTime < 2e3) {
30021
30036
  return;
30022
30037
  }
30023
30038
  const changes = [];
@@ -30044,7 +30059,7 @@ ${codeSnippet.split("\n").filter((l) => !l.startsWith("<!--") || !l.endsWith("--
30044
30059
  fileMTimes.delete(filePath);
30045
30060
  }
30046
30061
  }
30047
- if (changes.length || forcedRedeploy) {
30062
+ if (changes.length || forcedRepublish) {
30048
30063
  waiting = false;
30049
30064
  if (!firstRun) {
30050
30065
  if (lastRunWasError)
@@ -30052,11 +30067,11 @@ ${codeSnippet.split("\n").filter((l) => !l.startsWith("<!--") || !l.endsWith("--
30052
30067
  else
30053
30068
  hideShortcuts();
30054
30069
  console.log(
30055
- `${c12.blue("Info:")} ${forcedRedeploy ? "Requesting redeploy" : changes.length > 1 ? "Multiple changes detected" : `${path6.relative(directory, changes[0]).replace(/\\/g, "/")} changed`}, redeploying...`
30070
+ `${c12.blue("Info:")} ${forcedRepublish ? "Requesting republish" : changes.length > 1 ? "Multiple changes detected" : `${path6.relative(directory, changes[0]).replace(/\\/g, "/")} changed`}, republishing...`
30056
30071
  );
30057
30072
  }
30058
- forcedRedeploy = false;
30059
- ({ packageUrl, codeSnippet } = await deployOnce(
30073
+ forcedRepublish = false;
30074
+ ({ packageUrl, codeSnippet } = await publishOnce(
30060
30075
  name,
30061
30076
  version3,
30062
30077
  directory,
@@ -30064,7 +30079,7 @@ ${codeSnippet.split("\n").filter((l) => !l.startsWith("<!--") || !l.endsWith("--
30064
30079
  (flags.usage ?? true) && firstRun,
30065
30080
  prepareScript
30066
30081
  ));
30067
- lastDeployTime = Date.now();
30082
+ lastPublishTime = Date.now();
30068
30083
  showShortcuts(directory);
30069
30084
  lastRunWasError = false;
30070
30085
  waiting = true;
@@ -33056,19 +33071,30 @@ Uses RollupJS under the hood to create optimized bundles.
33056
33071
 
33057
33072
  The package entry points as defined in the package.json "exports" field are built, with the
33058
33073
  entire package copied into the output directory. As such, it is a whole-package transformation.
33074
+
33075
+ Build externals are taken from the package.json "dependencies" to form a roughly configurationless
33076
+ build workflow (dependencies in "devDependencies" or otherwise are inlined into the build).
33077
+
33059
33078
  Includes and ignores can be specified using the package.json "files" and "ignore" fields,
33060
33079
  optionally using the JSPM overrides for these via the "jspm" property in the package.json.
33080
+
33081
+ Any build import map shoud be generated separately via a subsequent install operation on the
33082
+ build folder, for example like:
33083
+
33084
+ ${c17.bold("jspm install -d dist -C production --flatten-scopes --combine-subpaths")}
33085
+
33086
+ to generate an optimized production map.
33061
33087
  `
33062
33088
  ).action(wrapCommand(build));
33063
33089
  outputOpts(
33064
33090
  generateOpts(
33065
- cli.command("deploy", `Deploy package to a provider (experimental)`).option(
33091
+ cli.command("publish", `Publish package to a provider (experimental)`).option(
33066
33092
  "--no-usage",
33067
- "Disable printing HTML/JS import code examples after successful deployment",
33093
+ "Disable printing HTML/JS import code examples after successful publish",
33068
33094
  {
33069
33095
  default: true
33070
33096
  }
33071
- ).option("-w, --watch", "Watch for changes and redeploy (experimental)", {
33097
+ ).option("-w, --watch", "Watch for changes and republish (experimental)", {
33072
33098
  default: false
33073
33099
  }).option(
33074
33100
  "-n, --name <name>",
@@ -33078,60 +33104,60 @@ outputOpts(
33078
33104
  "-v, --version <version>",
33079
33105
  "Publish with a custom version instead of the version from package.json",
33080
33106
  {}
33081
- ).option("--eject <package>", "Eject a deployed package instead of publishing", {}),
33107
+ ).option("--eject <package>", "Eject a published package instead of publishing", {}),
33082
33108
  true
33083
33109
  ),
33084
33110
  true
33085
33111
  ).example(
33086
33112
  (name) => `
33087
- $ ${name} deploy
33113
+ $ ${name} publish
33088
33114
 
33089
- Deploy the current directory as a package to the JSPM CDN.
33115
+ Publish the current directory as a package to the JSPM CDN.
33090
33116
  `
33091
33117
  ).example(
33092
33118
  (name) => `
33093
- $ ${name} deploy -p jspm.io
33119
+ $ ${name} publish -p jspm.io
33094
33120
 
33095
- Deploy the current package as a package to the JSPM CDN.
33121
+ Publish the current package as a package to the JSPM CDN.
33096
33122
  `
33097
33123
  ).example(
33098
33124
  (name) => `
33099
- $ ${name} deploy --dir dist --version dev-feat-2 --watch
33125
+ $ ${name} publish --dir dist --version dev-feat-2 --watch
33100
33126
 
33101
- Start a watched deployment to a custom mutable version tag (dev-feat-2) instead of the version from package.json.
33127
+ Start a watched publish to a custom mutable version tag (dev-feat-2) instead of the version from package.json.
33102
33128
  `
33103
33129
  ).example(
33104
33130
  (name) => `
33105
- $ ${name} deploy --eject app:foo@bar --dir foo
33131
+ $ ${name} publish --eject app:foo@bar --dir foo
33106
33132
 
33107
33133
  Download the application package foo@bar into the folder foo, merging its import map into foo/importmap.js.
33108
33134
  `
33109
33135
  ).example(
33110
33136
  (name) => `
33111
- $ ${name} deploy --eject app:foo@bar --dir foo -o test.html
33137
+ $ ${name} publish --eject app:foo@bar --dir foo -o test.html
33112
33138
 
33113
33139
  Download the application package foo@bar into the folder foo, merging its import map into the provided HTML file.
33114
33140
  `
33115
33141
  ).usage(
33116
- `deploy [options]
33142
+ `publish [options]
33117
33143
 
33118
- Manages deployments to the JSPM providers, currently in experimental preview.
33144
+ Manages publishes to the JSPM providers, currently in experimental preview.
33119
33145
 
33120
33146
  For publishing (default):
33121
33147
 
33122
- jspm deploy
33148
+ jspm publish
33123
33149
 
33124
33150
  - The provider flag is always required, with limited signups only available on the jspm.io provider currently
33125
33151
  - The package must have a valid package.json with name and version fields.
33126
33152
  - The package.json "files" and "ignore" arrays will be respected.
33127
- - Semver versions are always immutable deployments that cannot be redeployed.
33128
- - Mutable versions supporting redeployment must only contain alphanumeric characters, hyphens, and underscores [a-zA-Z0-9_-].
33153
+ - Semver versions are always immutable publishes that cannot be republished.
33154
+ - Mutable versions supporting republishing must only contain alphanumeric characters, hyphens, and underscores [a-zA-Z0-9_-].
33129
33155
 
33130
33156
  For ejecting a published package:
33131
33157
 
33132
- jspm deploy --eject <packagename@packageversion> --dir <directory>
33158
+ jspm download --eject <packagename@packageversion> --dir <directory>
33133
33159
 
33134
- - Ejects a deployed package into a local directory, stitching its deployment import map into the target import map.
33160
+ - Ejects a published package into a local directory, stitching its published import map into the target import map.
33135
33161
  - The --dir flag is required to specify the output project directory when using --eject.
33136
33162
  `
33137
33163
  ).action(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jspm",
3
3
  "type": "module",
4
- "version": "4.0.1",
4
+ "version": "4.0.3",
5
5
  "description": "Import Map Package Manager",
6
6
  "license": "Apache-2.0",
7
7
  "bin": {
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@babel/core": "^7.24.7",
20
- "@jspm/generator": "^2.6.0",
20
+ "@jspm/generator": "^2.6.1",
21
21
  "@jspm/plugin-rollup": "^1.2.4",
22
22
  "ora": "^8.2.0",
23
23
  "picocolors": "^1.1.1"