@jsenv/core 29.1.6 → 29.1.8

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/main.js CHANGED
@@ -2855,8 +2855,9 @@ function isUnicodeSupported() {
2855
2855
  }
2856
2856
 
2857
2857
  return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) // Windows Terminal
2858
+ || Boolean(process$1.env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
2858
2859
  || process$1.env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
2859
- || process$1.env.TERM_PROGRAM === 'vscode' || process$1.env.TERM === 'xterm-256color' || process$1.env.TERM === 'alacritty' || process$1.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
2860
+ || process$1.env.TERM_PROGRAM === 'Terminus-Sublime' || process$1.env.TERM_PROGRAM === 'vscode' || process$1.env.TERM === 'xterm-256color' || process$1.env.TERM === 'alacritty' || process$1.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
2860
2861
  }
2861
2862
 
2862
2863
  // see also https://github.com/sindresorhus/figures
@@ -3197,7 +3198,7 @@ const ESC = '\u001B[';
3197
3198
  const OSC = '\u001B]';
3198
3199
  const BEL = '\u0007';
3199
3200
  const SEP = ';';
3200
- const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
3201
+ const isTerminalApp = process$1.env.TERM_PROGRAM === 'Apple_Terminal';
3201
3202
  const ansiEscapes = {};
3202
3203
 
3203
3204
  ansiEscapes.cursorTo = (x, y) => {
@@ -3209,7 +3210,7 @@ ansiEscapes.cursorTo = (x, y) => {
3209
3210
  return ESC + (x + 1) + 'G';
3210
3211
  }
3211
3212
 
3212
- return ESC + (y + 1) + ';' + (x + 1) + 'H';
3213
+ return ESC + (y + 1) + SEP + (x + 1) + 'H';
3213
3214
  };
3214
3215
 
3215
3216
  ansiEscapes.cursorMove = (x, y) => {
@@ -3274,16 +3275,14 @@ ansiEscapes.eraseScreen = ESC + '2J';
3274
3275
  ansiEscapes.scrollUp = ESC + 'S';
3275
3276
  ansiEscapes.scrollDown = ESC + 'T';
3276
3277
  ansiEscapes.clearScreen = '\u001Bc';
3277
- ansiEscapes.clearTerminal = process.platform === 'win32' ? `${ansiEscapes.eraseScreen}${ESC}0f` : // 1. Erases the screen (Only done in case `2` is not supported)
3278
+ ansiEscapes.clearTerminal = process$1.platform === 'win32' ? `${ansiEscapes.eraseScreen}${ESC}0f` // 1. Erases the screen (Only done in case `2` is not supported)
3278
3279
  // 2. Erases the whole screen including scrollback buffer
3279
3280
  // 3. Moves cursor to the top-left position
3280
3281
  // More info: https://www.real-world-systems.com/docs/ANSIcode.html
3281
- `${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`;
3282
+ : `${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`;
3282
3283
  ansiEscapes.beep = BEL;
3283
3284
 
3284
- ansiEscapes.link = (text, url) => {
3285
- return [OSC, '8', SEP, SEP, url, BEL, text, OSC, '8', SEP, SEP, BEL].join('');
3286
- };
3285
+ ansiEscapes.link = (text, url) => [OSC, '8', SEP, SEP, url, BEL, text, OSC, '8', SEP, SEP, BEL].join('');
3287
3286
 
3288
3287
  ansiEscapes.image = (buffer, options = {}) => {
3289
3288
  let returnValue = `${OSC}1337;File=inline=1`;
@@ -3304,8 +3303,9 @@ ansiEscapes.image = (buffer, options = {}) => {
3304
3303
  };
3305
3304
 
3306
3305
  ansiEscapes.iTerm = {
3307
- setCwd: (cwd = process.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
3308
- annotation: (message, options = {}) => {
3306
+ setCwd: (cwd = process$1.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
3307
+
3308
+ annotation(message, options = {}) {
3309
3309
  let returnValue = `${OSC}1337;`;
3310
3310
  const hasX = typeof options.x !== 'undefined';
3311
3311
  const hasY = typeof options.y !== 'undefined';
@@ -3325,6 +3325,7 @@ ansiEscapes.iTerm = {
3325
3325
 
3326
3326
  return returnValue + BEL;
3327
3327
  }
3328
+
3328
3329
  };
3329
3330
 
3330
3331
  /*
@@ -6293,7 +6294,7 @@ const startServer = async ({
6293
6294
  }) => {
6294
6295
  const statusType = statusToType(status);
6295
6296
  addRequestLog(requestNode, {
6296
- type: {
6297
+ type: status === 404 && request.pathname === "/favicon.ico" ? "debug" : {
6297
6298
  information: "info",
6298
6299
  success: "info",
6299
6300
  redirection: "info",
@@ -8549,7 +8550,7 @@ const createUrlInfoTransformer = ({
8549
8550
  sourcemaps,
8550
8551
  sourcemapsSourcesProtocol,
8551
8552
  sourcemapsSourcesContent,
8552
- sourcemapsRelativeSources,
8553
+ sourcemapsSourcesRelative,
8553
8554
  urlGraph,
8554
8555
  injectSourcemapPlaceholder,
8555
8556
  foundSourcemap
@@ -8739,7 +8740,7 @@ const createUrlInfoTransformer = ({
8739
8740
  sourcemapUrlInfo.contentType = "application/json";
8740
8741
  const sourcemap = urlInfo.sourcemap;
8741
8742
 
8742
- if (sourcemapsRelativeSources) {
8743
+ if (sourcemapsSourcesRelative) {
8743
8744
  sourcemap.sources = sourcemap.sources.map(source => {
8744
8745
  const sourceRelative = urlToRelativeUrl(source, urlInfo.url);
8745
8746
  return sourceRelative || ".";
@@ -8767,7 +8768,7 @@ const createUrlInfoTransformer = ({
8767
8768
  urlInfo.content = SOURCEMAP.writeComment({
8768
8769
  contentType: urlInfo.contentType,
8769
8770
  content: urlInfo.content,
8770
- specifier: sourcemaps === "file" && sourcemapsRelativeSources ? urlToRelativeUrl(sourcemapReference.url, urlInfo.url) : sourcemapReference.generatedSpecifier
8771
+ specifier: sourcemaps === "file" && sourcemapsSourcesRelative ? urlToRelativeUrl(sourcemapReference.url, urlInfo.url) : sourcemapReference.generatedSpecifier
8771
8772
  });
8772
8773
  }
8773
8774
  }
@@ -9502,7 +9503,7 @@ const createKitchen = ({
9502
9503
  // "programmatic" and "file" also allowed
9503
9504
  sourcemapsSourcesProtocol,
9504
9505
  sourcemapsSourcesContent,
9505
- sourcemapsRelativeSources,
9506
+ sourcemapsSourcesRelative,
9506
9507
  writeGeneratedFiles,
9507
9508
  outDirectoryUrl
9508
9509
  }) => {
@@ -9718,7 +9719,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
9718
9719
  sourcemaps,
9719
9720
  sourcemapsSourcesProtocol,
9720
9721
  sourcemapsSourcesContent,
9721
- sourcemapsRelativeSources,
9722
+ sourcemapsSourcesRelative,
9722
9723
  clientRuntimeCompat,
9723
9724
  injectSourcemapPlaceholder: ({
9724
9725
  urlInfo,
@@ -10078,7 +10079,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
10078
10079
  } = urlInfo;
10079
10080
 
10080
10081
  if (generatedUrl && generatedUrl.startsWith("file:")) {
10081
- if (urlInfo.type === "directory") ; else {
10082
+ if (urlInfo.type === "directory") ; else if (urlInfo.content === null) ; else {
10082
10083
  writeFileSync(new URL(generatedUrl), urlInfo.content);
10083
10084
  const {
10084
10085
  sourcemapGeneratedUrl,
@@ -10284,8 +10285,8 @@ const adjustUrlSite = (urlInfo, {
10284
10285
  isOriginal: true,
10285
10286
  url: inlineUrlSite.url,
10286
10287
  content: inlineUrlSite.content,
10287
- line: inlineUrlSite.line + urlSite.line,
10288
- column: inlineUrlSite.column + urlSite.column
10288
+ line: inlineUrlSite.line === undefined ? urlSite.line : inlineUrlSite.line + urlSite.line,
10289
+ column: inlineUrlSite.column === undefined ? urlSite.column : inlineUrlSite.column + urlSite.column
10289
10290
  }, parentUrlInfo);
10290
10291
  };
10291
10292
 
@@ -16473,10 +16474,25 @@ const convertJsModuleToJsClassic = async ({
16473
16474
 
16474
16475
  if (systemJsInjection && jsClassicFormat === "system" && urlInfo.isEntryPoint) {
16475
16476
  const magicSource = createMagicSource(code);
16476
- const systemjsCode = readFileSync(systemJsClientFileUrl, {
16477
+ let systemJsFileContent = readFileSync(systemJsClientFileUrl, {
16477
16478
  as: "string"
16478
16479
  });
16479
- magicSource.prepend(`${systemjsCode}\n\n`);
16480
+ const sourcemapFound = SOURCEMAP.readComment({
16481
+ contentType: "text/javascript",
16482
+ content: systemJsFileContent
16483
+ });
16484
+
16485
+ if (sourcemapFound) {
16486
+ // for now let's remove s.js sourcemap
16487
+ // because it would likely mess the sourcemap of the entry point itself
16488
+ systemJsFileContent = SOURCEMAP.writeComment({
16489
+ contentType: "text/javascript",
16490
+ content: systemJsFileContent,
16491
+ specifier: ""
16492
+ });
16493
+ }
16494
+
16495
+ magicSource.prepend(`${systemJsFileContent}\n\n`);
16480
16496
  const magicResult = magicSource.toContentAndSourcemap();
16481
16497
  sourcemap = await composeTwoSourcemaps(sourcemap, magicResult.sourcemap);
16482
16498
  return {
@@ -16500,14 +16516,42 @@ const jsenvPluginAsJsClassicConversion = ({
16500
16516
  systemJsClientFileUrl,
16501
16517
  generateJsClassicFilename
16502
16518
  }) => {
16519
+ const isReferencingJsModule = reference => {
16520
+ if (reference.type === "js_import_export" || reference.subtype === "system_register_arg" || reference.subtype === "system_import_arg") {
16521
+ return true;
16522
+ }
16523
+
16524
+ if (reference.type === "js_url_specifier") {
16525
+ if (reference.expectedType === "js_classic") {
16526
+ return false;
16527
+ }
16528
+
16529
+ if (reference.expectedType === undefined && CONTENT_TYPE.fromUrlExtension(reference.url) === "text/javascript") {
16530
+ // by default, js referenced by new URL is considered as "js_module"
16531
+ // in case this is not desired code must use "?js_classic" like
16532
+ // new URL('./file.js?js_classic', import.meta.url)
16533
+ return true;
16534
+ }
16535
+ }
16536
+
16537
+ return false;
16538
+ };
16539
+
16503
16540
  const shouldPropagateJsClassic = (reference, context) => {
16504
- const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl);
16541
+ if (isReferencingJsModule(reference)) {
16542
+ const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl);
16505
16543
 
16506
- if (!parentUrlInfo) {
16507
- return false;
16544
+ if (!parentUrlInfo) {
16545
+ return false;
16546
+ } // if (parentUrlInfo.isEntryPoint) {
16547
+ // return true
16548
+ // }
16549
+
16550
+
16551
+ return new URL(parentUrlInfo.url).searchParams.has("as_js_classic");
16508
16552
  }
16509
16553
 
16510
- return new URL(parentUrlInfo.url).searchParams.has("as_js_classic");
16554
+ return false;
16511
16555
  };
16512
16556
 
16513
16557
  const markAsJsClassicProxy = reference => {
@@ -16530,18 +16574,16 @@ const jsenvPluginAsJsClassicConversion = ({
16530
16574
  if (reference.searchParams.has("as_js_classic")) {
16531
16575
  markAsJsClassicProxy(reference);
16532
16576
  return null;
16533
- }
16577
+ } // We want to propagate transformation of js module to js classic to:
16578
+ // - import specifier (static/dynamic import + re-export)
16579
+ // - url specifier when inside System.register/_context.import()
16580
+ // (because it's the transpiled equivalent of static and dynamic imports)
16581
+ // And not other references otherwise we could try to transform inline resources
16582
+ // or specifiers inside new URL()...
16534
16583
 
16535
- if (reference.type === "js_import_export" || reference.subtype === "system_register_arg" || reference.subtype === "system_import_arg") {
16536
- // We want to propagate transformation of js module to js classic to:
16537
- // - import specifier (static/dynamic import + re-export)
16538
- // - url specifier when inside System.register/_context.import()
16539
- // (because it's the transpiled equivalent of static and dynamic imports)
16540
- // And not other references otherwise we could try to transform inline resources
16541
- // or specifiers inside new URL()...
16542
- if (shouldPropagateJsClassic(reference, context)) {
16543
- return turnIntoJsClassicProxy(reference);
16544
- }
16584
+
16585
+ if (shouldPropagateJsClassic(reference, context)) {
16586
+ return turnIntoJsClassicProxy(reference);
16545
16587
  }
16546
16588
 
16547
16589
  return null;
@@ -16752,9 +16794,23 @@ const jsenvPluginAsJsClassicHtml = ({
16752
16794
 
16753
16795
  if (needsSystemJs) {
16754
16796
  mutations.push(async () => {
16755
- const systemJsFileContent = readFileSync$1(new URL(systemJsClientFileUrl), {
16797
+ let systemJsFileContent = readFileSync$1(new URL(systemJsClientFileUrl), {
16756
16798
  encoding: "utf8"
16757
16799
  });
16800
+ const sourcemapFound = SOURCEMAP.readComment({
16801
+ contentType: "text/javascript",
16802
+ content: systemJsFileContent
16803
+ });
16804
+
16805
+ if (sourcemapFound) {
16806
+ const sourcemapFileUrl = new URL(sourcemapFound.specifier, systemJsClientFileUrl);
16807
+ systemJsFileContent = SOURCEMAP.writeComment({
16808
+ contentType: "text/javascript",
16809
+ content: systemJsFileContent,
16810
+ specifier: urlToRelativeUrl(sourcemapFileUrl, urlInfo.url)
16811
+ });
16812
+ }
16813
+
16758
16814
  const [systemJsReference, systemJsUrlInfo] = context.referenceUtils.inject({
16759
16815
  type: "script_src",
16760
16816
  expectedType: "js_classic",
@@ -17028,24 +17084,34 @@ const rollupPluginJsenv = ({
17028
17084
  const rollupFileInfo = rollupResult[fileName]; // there is 3 types of file: "placeholder", "asset", "chunk"
17029
17085
 
17030
17086
  if (rollupFileInfo.type === "chunk") {
17087
+ const sourceUrls = Object.keys(rollupFileInfo.modules).map(id => fileUrlConverter.asFileUrl(id));
17031
17088
  let url;
17089
+ let originalUrl;
17032
17090
 
17033
17091
  if (rollupFileInfo.facadeModuleId) {
17034
17092
  url = fileUrlConverter.asFileUrl(rollupFileInfo.facadeModuleId);
17093
+ originalUrl = url;
17035
17094
  } else {
17036
17095
  url = new URL(rollupFileInfo.fileName, buildDirectoryUrl).href;
17096
+
17097
+ if (rollupFileInfo.isDynamicEntry) {
17098
+ originalUrl = sourceUrls[sourceUrls.length - 1];
17099
+ } else {
17100
+ originalUrl = url;
17101
+ }
17037
17102
  }
17038
17103
 
17039
17104
  const jsModuleBundleUrlInfo = {
17040
17105
  url,
17041
- originalUrl: url,
17106
+ originalUrl,
17042
17107
  type: format === "esm" ? "js_module" : "common_js",
17043
17108
  data: {
17044
17109
  generatedBy: "rollup",
17045
17110
  bundleRelativeUrl: rollupFileInfo.fileName,
17046
- usesImport: rollupFileInfo.imports.length > 0 || rollupFileInfo.dynamicImports.length > 0
17111
+ usesImport: rollupFileInfo.imports.length > 0 || rollupFileInfo.dynamicImports.length > 0,
17112
+ isDynamicEntry: rollupFileInfo.isDynamicEntry
17047
17113
  },
17048
- sourceUrls: Object.keys(rollupFileInfo.modules).map(id => fileUrlConverter.asFileUrl(id)),
17114
+ sourceUrls,
17049
17115
  contentType: "text/javascript",
17050
17116
  content: rollupFileInfo.code,
17051
17117
  sourcemap: rollupFileInfo.map
@@ -23904,7 +23970,7 @@ build ${entryPointKeys.length} entry points`);
23904
23970
  const buildUrlsGenerator = createBuilUrlsGenerator({
23905
23971
  buildDirectoryUrl
23906
23972
  });
23907
- const buildToRawUrls = {}; // rename "buildDirectoryRedirections"?
23973
+ const buildDirectoryRedirections = new Map();
23908
23974
 
23909
23975
  const associateBuildUrlAndRawUrl = (buildUrl, rawUrl, reason) => {
23910
23976
  if (urlIsInsideOf(rawUrl, buildDirectoryUrl)) {
@@ -23915,7 +23981,7 @@ build ${entryPointKeys.length} entry points`);
23915
23981
  ${ANSI.color(rawUrl, ANSI.GREY)} ->
23916
23982
  ${ANSI.color(buildUrl, ANSI.MAGENTA)}
23917
23983
  `);
23918
- buildToRawUrls[buildUrl] = rawUrl;
23984
+ buildDirectoryRedirections.set(buildUrl, rawUrl);
23919
23985
  };
23920
23986
 
23921
23987
  const buildUrls = new Map();
@@ -23946,7 +24012,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
23946
24012
  resolveUrl: reference => {
23947
24013
  const getUrl = () => {
23948
24014
  if (reference.type === "filesystem") {
23949
- const parentRawUrl = buildToRawUrls[reference.parentUrl];
24015
+ const parentRawUrl = buildDirectoryRedirections.get(reference.parentUrl);
23950
24016
  const baseUrl = ensurePathnameTrailingSlash(parentRawUrl);
23951
24017
  return new URL(reference.specifier, baseUrl).href;
23952
24018
  }
@@ -23977,7 +24043,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
23977
24043
  } // already a build url
23978
24044
 
23979
24045
 
23980
- const rawUrl = buildToRawUrls[reference.url];
24046
+ const rawUrl = buildDirectoryRedirections.get(reference.url);
23981
24047
 
23982
24048
  if (rawUrl) {
23983
24049
  return reference.url;
@@ -24147,14 +24213,14 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24147
24213
  return bundleUrlInfo;
24148
24214
  }
24149
24215
 
24150
- const rawUrl = buildToRawUrls[url] || url;
24216
+ const rawUrl = buildDirectoryRedirections.get(url) || url;
24151
24217
  const rawUrlInfo = rawGraph.getUrlInfo(rawUrl);
24152
24218
 
24153
24219
  if (!rawUrlInfo) {
24154
24220
  throw new Error(createDetailedMessage$1(`Cannot find url`, {
24155
24221
  url,
24156
- "raw urls": Object.values(buildToRawUrls),
24157
- "build urls": Object.keys(buildToRawUrls)
24222
+ "raw urls": Array.from(buildDirectoryRedirections.values()),
24223
+ "build urls": Array.from(buildDirectoryRedirections.keys())
24158
24224
  }));
24159
24225
  } // logger.debug(`fetching from raw graph ${url}`)
24160
24226
 
@@ -24183,7 +24249,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24183
24249
 
24184
24250
  if (reference.injected) {
24185
24251
  const [ref, rawUrlInfo] = rawGraphKitchen.injectReference({ ...reference,
24186
- parentUrl: buildToRawUrls[reference.parentUrl]
24252
+ parentUrl: buildDirectoryRedirections.get(reference.parentUrl)
24187
24253
  });
24188
24254
  await rawGraphKitchen.cook(rawUrlInfo, {
24189
24255
  reference: ref
@@ -24214,7 +24280,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24214
24280
  }],
24215
24281
  sourcemaps,
24216
24282
  sourcemapsSourcesContent,
24217
- sourcemapsRelativeSources: !versioning,
24283
+ sourcemapsSourcesRelative: !versioning,
24218
24284
  writeGeneratedFiles,
24219
24285
  outDirectoryUrl: new URL(".jsenv/postbuild/", rootDirectoryUrl)
24220
24286
  });
@@ -24398,10 +24464,10 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24398
24464
 
24399
24465
  if (bundlerGeneratedUrlInfo.sourceUrls) {
24400
24466
  bundlerGeneratedUrlInfo.sourceUrls.forEach(sourceUrl => {
24401
- const rawUrlInfo = rawGraph.getUrlInfo(sourceUrl);
24467
+ const sourceRawUrlInfo = rawGraph.getUrlInfo(sourceUrl);
24402
24468
 
24403
- if (rawUrlInfo) {
24404
- rawUrlInfo.data.bundled = true;
24469
+ if (sourceRawUrlInfo) {
24470
+ sourceRawUrlInfo.data.bundled = true;
24405
24471
  }
24406
24472
  });
24407
24473
  }
@@ -24411,7 +24477,14 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24411
24477
  });
24412
24478
  bundleRedirections.set(url, buildUrl);
24413
24479
 
24414
- if (urlIsInsideOf(url, buildDirectoryUrl)) {// chunk generated by rollup to share code
24480
+ if (urlIsInsideOf(url, buildDirectoryUrl)) {
24481
+ if (bundlerGeneratedUrlInfo.data.isDynamicEntry) {
24482
+ const rawUrlInfo = rawGraph.getUrlInfo(bundlerGeneratedUrlInfo.originalUrl);
24483
+ rawUrlInfo.data.bundled = false;
24484
+ bundleRedirections.set(bundlerGeneratedUrlInfo.originalUrl, buildUrl);
24485
+ associateBuildUrlAndRawUrl(buildUrl, bundlerGeneratedUrlInfo.originalUrl, "bundle");
24486
+ } else {// chunk generated by rollup to share code
24487
+ }
24415
24488
  } else {
24416
24489
  associateBuildUrlAndRawUrl(buildUrl, url, "bundle");
24417
24490
  }
@@ -24674,7 +24747,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24674
24747
  },
24675
24748
  fetchUrlContent: versionedUrlInfo => {
24676
24749
  if (versionedUrlInfo.isInline) {
24677
- const rawUrlInfo = rawGraph.getUrlInfo(buildToRawUrls[versionedUrlInfo.url]);
24750
+ const rawUrlInfo = rawGraph.getUrlInfo(buildDirectoryRedirections.get(versionedUrlInfo.url));
24678
24751
  const finalUrlInfo = finalGraph.getUrlInfo(versionedUrlInfo.url);
24679
24752
  return {
24680
24753
  content: versionedUrlInfo.content,
@@ -24689,7 +24762,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24689
24762
  }],
24690
24763
  sourcemaps,
24691
24764
  sourcemapsSourcesContent,
24692
- sourcemapsRelativeSources: true,
24765
+ sourcemapsSourcesRelative: true,
24693
24766
  writeGeneratedFiles,
24694
24767
  outDirectoryUrl: new URL(".jsenv/postbuild/", finalGraphKitchen.rootDirectoryUrl)
24695
24768
  });
@@ -24759,7 +24832,8 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24759
24832
  /*
24760
24833
  * Update <link rel="preload"> and friends after build (once we know everything)
24761
24834
  * - Used to remove resource hint targeting an url that is no longer used:
24762
- * - Happens because of import assertions transpilation (file is inlined into JS)
24835
+ * - because of bundlings
24836
+ * - because of import assertions transpilation (file is inlined into JS)
24763
24837
  */
24764
24838
 
24765
24839
 
@@ -24802,7 +24876,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24802
24876
  }
24803
24877
 
24804
24878
  if (buildUrlInfo.dependents.size === 0) {
24805
- logger.info(`remove resource hint because "${href}" not used anymore`);
24879
+ logger.warn(`remove resource hint because "${href}" not used anymore`);
24806
24880
  mutations.push(() => {
24807
24881
  removeHtmlNode(node);
24808
24882
  });
@@ -24825,7 +24899,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24825
24899
  const rawUrlInfo = rawGraph.getUrlInfo(url);
24826
24900
 
24827
24901
  if (rawUrlInfo && rawUrlInfo.data.bundled) {
24828
- logger.info(`remove resource hint on "${href}" because it was bundled`);
24902
+ logger.warn(`remove resource hint on "${href}" because it was bundled`);
24829
24903
  mutations.push(() => {
24830
24904
  removeHtmlNode(node);
24831
24905
  });
@@ -24833,6 +24907,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24833
24907
  url = bundleRedirections.get(url) || url;
24834
24908
  url = bundleInternalRedirections.get(url) || url;
24835
24909
  url = finalRedirections.get(url) || url;
24910
+ url = findKey(buildDirectoryRedirections, url) || url;
24836
24911
  onBuildUrl(url);
24837
24912
  }
24838
24913
  } else {
@@ -25454,7 +25529,18 @@ const createFileService = ({
25454
25529
  }
25455
25530
 
25456
25531
  if (!watch) {
25457
- const fileContentAsBuffer = readFileSync$1(new URL(urlInfo.url));
25532
+ let fileContentAsBuffer;
25533
+
25534
+ try {
25535
+ fileContentAsBuffer = readFileSync$1(new URL(urlInfo.url));
25536
+ } catch (e) {
25537
+ if (e.code === "ENOENT") {
25538
+ return false;
25539
+ }
25540
+
25541
+ return false;
25542
+ }
25543
+
25458
25544
  const fileContentEtag = bufferToEtag$1(fileContentAsBuffer);
25459
25545
 
25460
25546
  if (fileContentEtag !== urlInfo.originalContentEtag) {
@@ -25575,27 +25661,27 @@ const createFileService = ({
25575
25661
  const ifNoneMatch = request.headers["if-none-match"];
25576
25662
  const urlInfoTargetedByCache = urlGraph.getParentIfInline(urlInfo);
25577
25663
 
25578
- if (ifNoneMatch) {
25579
- const [clientOriginalContentEtag, clientContentEtag] = ifNoneMatch.split("_");
25664
+ try {
25665
+ if (ifNoneMatch) {
25666
+ const [clientOriginalContentEtag, clientContentEtag] = ifNoneMatch.split("_");
25667
+
25668
+ if (urlInfoTargetedByCache.originalContentEtag === clientOriginalContentEtag && urlInfoTargetedByCache.contentEtag === clientContentEtag && urlInfoTargetedByCache.isValid()) {
25669
+ const headers = {
25670
+ "cache-control": `private,max-age=0,must-revalidate`
25671
+ };
25672
+ Object.keys(urlInfo.headers).forEach(key => {
25673
+ if (key !== "content-length") {
25674
+ headers[key] = urlInfo.headers[key];
25675
+ }
25676
+ });
25677
+ return {
25678
+ status: 304,
25679
+ headers
25680
+ };
25681
+ }
25682
+ } // urlInfo objects are reused, they must be "reset" before cooking them again
25580
25683
 
25581
- if (urlInfoTargetedByCache.originalContentEtag === clientOriginalContentEtag && urlInfoTargetedByCache.contentEtag === clientContentEtag && urlInfoTargetedByCache.isValid()) {
25582
- const headers = {
25583
- "cache-control": `private,max-age=0,must-revalidate`
25584
- };
25585
- Object.keys(urlInfo.headers).forEach(key => {
25586
- if (key !== "content-length") {
25587
- headers[key] = urlInfo.headers[key];
25588
- }
25589
- });
25590
- return {
25591
- status: 304,
25592
- headers
25593
- };
25594
- }
25595
- }
25596
25684
 
25597
- try {
25598
- // urlInfo objects are reused, they must be "reset" before cooking them again
25599
25685
  if ((urlInfo.error || urlInfo.contentEtag) && !urlInfo.isInline && urlInfo.type !== "sourcemap") {
25600
25686
  urlInfo.error = null;
25601
25687
  urlInfo.sourcemap = null;
@@ -29602,6 +29688,12 @@ const startBuildServer = async ({
29602
29688
  })]
29603
29689
  });
29604
29690
  startBuildServerTask.done();
29691
+
29692
+ if (hostname) {
29693
+ delete server.origins.localip;
29694
+ delete server.origins.externalip;
29695
+ }
29696
+
29605
29697
  logger.info(``);
29606
29698
  Object.keys(server.origins).forEach(key => {
29607
29699
  logger.info(`- ${server.origins[key]}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "29.1.6",
3
+ "version": "29.1.8",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -66,14 +66,14 @@
66
66
  "@c88/v8-coverage": "0.1.1",
67
67
  "@financial-times/polyfill-useragent-normaliser": "1.10.2",
68
68
  "@jsenv/abort": "4.2.4",
69
- "@jsenv/ast": "1.3.0",
69
+ "@jsenv/ast": "1.3.2",
70
70
  "@jsenv/babel-plugins": "1.0.7",
71
71
  "@jsenv/filesystem": "4.1.3",
72
72
  "@jsenv/importmap": "1.2.1",
73
73
  "@jsenv/integrity": "0.0.1",
74
- "@jsenv/log": "3.3.0",
74
+ "@jsenv/log": "3.3.1",
75
75
  "@jsenv/node-esm-resolution": "0.1.0",
76
- "@jsenv/server": "14.1.5",
76
+ "@jsenv/server": "14.1.7",
77
77
  "@jsenv/sourcemap": "1.0.5",
78
78
  "@jsenv/uneval": "1.6.0",
79
79
  "@jsenv/url-meta": "7.0.0",
@@ -89,7 +89,7 @@
89
89
  "istanbul-reports": "3.1.5",
90
90
  "launch-editor": "2.6.0",
91
91
  "pidtree": "0.6.0",
92
- "rollup": "2.79.0",
92
+ "rollup": "2.79.1",
93
93
  "string-width": "5.1.2",
94
94
  "strip-ansi": "7.0.1",
95
95
  "terser": "5.15.0",
@@ -97,7 +97,7 @@
97
97
  "wrap-ansi": "8.0.1"
98
98
  },
99
99
  "devDependencies": {
100
- "@babel/eslint-parser": "7.18.9",
100
+ "@babel/eslint-parser": "7.19.1",
101
101
  "@babel/plugin-syntax-import-assertions": "7.18.6",
102
102
  "@jsenv/assert": "2.7.0",
103
103
  "@jsenv/eslint-config": "16.2.1",
@@ -105,11 +105,11 @@
105
105
  "@jsenv/https-local": "3.0.1",
106
106
  "@jsenv/package-workspace": "0.5.0",
107
107
  "@jsenv/performance-impact": "3.0.1",
108
- "eslint": "8.23.0",
108
+ "eslint": "8.23.1",
109
109
  "eslint-plugin-html": "7.1.0",
110
110
  "eslint-plugin-import": "2.26.0",
111
- "eslint-plugin-react": "7.31.7",
112
- "playwright": "1.25.1",
111
+ "eslint-plugin-react": "7.31.8",
112
+ "playwright": "1.26.0",
113
113
  "prettier": "2.7.1"
114
114
  }
115
115
  }