@jsenv/core 38.0.2 → 38.0.4

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.
@@ -8258,19 +8258,6 @@ const versionToBits$2 = (version) => {
8258
8258
  return (major << 16) | (minor << 8) | patch;
8259
8259
  };
8260
8260
 
8261
- /*
8262
- * TODO:
8263
- * js classic might contain importScripts or self.importScripts calls
8264
- * (when it's inside worker, service worker, etc...)
8265
- * ideally we should bundle it when urlInfo.subtype === "worker"
8266
- */
8267
-
8268
- // import { createMagicSource } from "@jsenv/utils/sourcemap/magic_source.js"
8269
-
8270
- const bundleJsClassic = () => {
8271
- return {};
8272
- };
8273
-
8274
8261
  const bundleJsModules = async (
8275
8262
  jsModuleUrlInfos,
8276
8263
  {
@@ -8707,11 +8694,6 @@ const jsenvPluginBundling = ({
8707
8694
  return bundleCss(cssUrlInfos);
8708
8695
  };
8709
8696
  }
8710
- if (js_classic) {
8711
- bundle.js_classic = (jsClassicUrlInfos) => {
8712
- return bundleJsClassic();
8713
- };
8714
- }
8715
8697
  if (js_module) {
8716
8698
  if (js_module === true) {
8717
8699
  js_module = {};
@@ -9231,7 +9213,7 @@ export default inlineContent.text;`,
9231
9213
  *
9232
9214
  */
9233
9215
  const babelHelperClientDirectoryUrl = new URL(
9234
- "../packages/internal/plugin-transpilation/src/babel/babel_helper_directory/babel_helpers/",
9216
+ "./babel_helpers/",
9235
9217
  import.meta.url,
9236
9218
  ).href;
9237
9219
 
@@ -12327,6 +12309,7 @@ const createUrlInfo = (url, context) => {
12327
12309
 
12328
12310
  sourcemap: null,
12329
12311
  sourcemapIsWrong: false,
12312
+ sourcemapReference: null,
12330
12313
 
12331
12314
  generatedUrl: null,
12332
12315
  sourcemapGeneratedUrl: null,
@@ -13101,14 +13084,10 @@ const createUrlInfoTransformer = ({
13101
13084
  sourcemapsComment,
13102
13085
  sourcemapsSources,
13103
13086
  sourcemapsSourcesProtocol,
13104
- sourcemapsSourcesContent,
13087
+ sourcemapsSourcesContent = true,
13105
13088
  outDirectoryUrl,
13106
13089
  supervisor,
13107
13090
  }) => {
13108
- if (sourcemapsSourcesContent === undefined) {
13109
- sourcemapsSourcesContent = true;
13110
- }
13111
-
13112
13091
  const formatSourcemapSource =
13113
13092
  typeof sourcemapsSources === "function"
13114
13093
  ? (source, urlInfo) => {
@@ -13167,6 +13146,7 @@ const createUrlInfoTransformer = ({
13167
13146
  urlInfo.content = undefined;
13168
13147
  urlInfo.sourcemap = null;
13169
13148
  urlInfo.sourcemapIsWrong = null;
13149
+ urlInfo.sourcemapReference = null;
13170
13150
  };
13171
13151
 
13172
13152
  const setContentProperties = (
@@ -13231,6 +13211,10 @@ const createUrlInfoTransformer = ({
13231
13211
  generatedUrlObject.searchParams.delete("js_module_fallback");
13232
13212
  generatedUrlObject.searchParams.delete("as_js_module");
13233
13213
  generatedUrlObject.searchParams.delete("as_js_classic");
13214
+ generatedUrlObject.searchParams.delete("as_css_module");
13215
+ generatedUrlObject.searchParams.delete("as_json_module");
13216
+ generatedUrlObject.searchParams.delete("as_text_module");
13217
+ generatedUrlObject.searchParams.delete("dynamic_import");
13234
13218
  const urlForSourcemap = generatedUrlObject.href;
13235
13219
  urlInfo.sourcemapGeneratedUrl = generateSourcemapFileUrl(urlForSourcemap);
13236
13220
 
@@ -13257,6 +13241,7 @@ const createUrlInfoTransformer = ({
13257
13241
  specifierLine: line,
13258
13242
  specifierColumn: column,
13259
13243
  });
13244
+ urlInfo.sourcemapReference = sourcemapReference;
13260
13245
  try {
13261
13246
  await sourcemapReference.urlInfo.cook();
13262
13247
  const sourcemapRaw = JSON.parse(sourcemapReference.urlInfo.content);
@@ -13370,11 +13355,11 @@ const createUrlInfoTransformer = ({
13370
13355
  if (!contentIsInlined) {
13371
13356
  writeFileSync(new URL(generatedUrl), urlInfo.content);
13372
13357
  }
13373
- const { sourcemapGeneratedUrl, sourcemap } = urlInfo;
13374
- if (sourcemapGeneratedUrl && sourcemap) {
13358
+ const { sourcemapGeneratedUrl, sourcemapReference } = urlInfo;
13359
+ if (sourcemapGeneratedUrl && sourcemapReference) {
13375
13360
  writeFileSync(
13376
13361
  new URL(sourcemapGeneratedUrl),
13377
- JSON.stringify(sourcemap, null, " "),
13362
+ sourcemapReference.urlInfo.content,
13378
13363
  );
13379
13364
  }
13380
13365
  };
@@ -13393,25 +13378,28 @@ const createUrlInfoTransformer = ({
13393
13378
  // in this scenarion we don't want to inject sourcemap reference
13394
13379
  // just update the content
13395
13380
 
13396
- let sourcemapReference = null;
13397
- for (const referenceToOther of urlInfo.referenceToOthersSet) {
13398
- if (referenceToOther.type === "sourcemap_comment") {
13399
- sourcemapReference = referenceToOther;
13400
- break;
13401
- }
13402
- }
13381
+ let sourcemapReference = urlInfo.sourcemapReference;
13403
13382
  if (!sourcemapReference) {
13404
- sourcemapReference = urlInfo.dependencies.inject({
13405
- trace: {
13406
- message: `sourcemap comment placeholder`,
13407
- url: urlInfo.url,
13408
- },
13409
- type: "sourcemap_comment",
13410
- subtype: urlInfo.contentType === "text/javascript" ? "js" : "css",
13411
- expectedType: "sourcemap",
13412
- specifier: urlInfo.sourcemapGeneratedUrl,
13413
- isInline: sourcemaps === "inline",
13414
- });
13383
+ for (const referenceToOther of urlInfo.referenceToOthersSet) {
13384
+ if (referenceToOther.type === "sourcemap_comment") {
13385
+ sourcemapReference = referenceToOther;
13386
+ break;
13387
+ }
13388
+ }
13389
+ if (!sourcemapReference) {
13390
+ sourcemapReference = urlInfo.dependencies.inject({
13391
+ trace: {
13392
+ message: `sourcemap comment placeholder`,
13393
+ url: urlInfo.url,
13394
+ },
13395
+ type: "sourcemap_comment",
13396
+ subtype: urlInfo.contentType === "text/javascript" ? "js" : "css",
13397
+ expectedType: "sourcemap",
13398
+ specifier: urlInfo.sourcemapGeneratedUrl,
13399
+ isInline: sourcemaps === "inline",
13400
+ });
13401
+ }
13402
+ urlInfo.sourcemapReference = sourcemapReference;
13415
13403
  }
13416
13404
  const sourcemapUrlInfo = sourcemapReference.urlInfo;
13417
13405
  // It's possible urlInfo content to be modified after being finalized
@@ -14324,6 +14312,9 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
14324
14312
 
14325
14313
  // urlInfo objects are reused, they must be "reset" before cooking them again
14326
14314
  if (urlInfo.error || urlInfo.content !== undefined) {
14315
+ if (urlInfo.isInline) {
14316
+ return;
14317
+ }
14327
14318
  urlInfo.error = null;
14328
14319
  urlInfo.type = null;
14329
14320
  urlInfo.subtype = null;
@@ -19771,7 +19762,12 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
19771
19762
  return buildUrlFromCache;
19772
19763
  }
19773
19764
  if (urlInfo.type === "directory") {
19774
- const directoryPath = urlToRelativeUrl(url, sourceDirectoryUrl);
19765
+ let directoryPath;
19766
+ if (urlInfo.filenameHint) {
19767
+ directoryPath = urlInfo.filenameHint;
19768
+ } else {
19769
+ directoryPath = urlToRelativeUrl(url, sourceDirectoryUrl);
19770
+ }
19775
19771
  const { search } = new URL(url);
19776
19772
  const buildUrl = `${buildDirectoryUrl}${directoryPath}${search}`;
19777
19773
  associateBuildUrl(url, buildUrl);
@@ -21463,8 +21459,8 @@ build ${entryPointKeys.length} entry points`);
21463
21459
  ? [jsenvPluginLineBreakNormalization()]
21464
21460
  : []),
21465
21461
  jsenvPluginJsModuleFallback({
21466
- remapImportSpecifier: (specifier) => {
21467
- return buildSpecifierManager.remapPlaceholder(specifier);
21462
+ remapImportSpecifier: (specifier, parentUrl) => {
21463
+ return buildSpecifierManager.remapPlaceholder(specifier, parentUrl);
21468
21464
  },
21469
21465
  }),
21470
21466
  jsenvPluginInlining(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "38.0.2",
3
+ "version": "38.0.4",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -67,7 +67,7 @@
67
67
  "@jsenv/integrity": "0.0.1",
68
68
  "@jsenv/log": "3.4.0",
69
69
  "@jsenv/node-esm-resolution": "1.0.1",
70
- "@jsenv/js-module-fallback": "1.3.0",
70
+ "@jsenv/js-module-fallback": "1.3.1",
71
71
  "@jsenv/runtime-compat": "1.2.0",
72
72
  "@jsenv/server": "15.1.0",
73
73
  "@jsenv/sourcemap": "1.2.0",
@@ -353,8 +353,8 @@ build ${entryPointKeys.length} entry points`);
353
353
  ? [jsenvPluginLineBreakNormalization()]
354
354
  : []),
355
355
  jsenvPluginJsModuleFallback({
356
- remapImportSpecifier: (specifier) => {
357
- return buildSpecifierManager.remapPlaceholder(specifier);
356
+ remapImportSpecifier: (specifier, parentUrl) => {
357
+ return buildSpecifierManager.remapPlaceholder(specifier, parentUrl);
358
358
  },
359
359
  }),
360
360
  jsenvPluginInlining(),
@@ -34,7 +34,12 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
34
34
  return buildUrlFromCache;
35
35
  }
36
36
  if (urlInfo.type === "directory") {
37
- const directoryPath = urlToRelativeUrl(url, sourceDirectoryUrl);
37
+ let directoryPath;
38
+ if (urlInfo.filenameHint) {
39
+ directoryPath = urlInfo.filenameHint;
40
+ } else {
41
+ directoryPath = urlToRelativeUrl(url, sourceDirectoryUrl);
42
+ }
38
43
  const { search } = new URL(url);
39
44
  const buildUrl = `${buildDirectoryUrl}${directoryPath}${search}`;
40
45
  associateBuildUrl(url, buildUrl);
@@ -456,6 +456,9 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
456
456
 
457
457
  // urlInfo objects are reused, they must be "reset" before cooking them again
458
458
  if (urlInfo.error || urlInfo.content !== undefined) {
459
+ if (urlInfo.isInline) {
460
+ return;
461
+ }
459
462
  urlInfo.error = null;
460
463
  urlInfo.type = null;
461
464
  urlInfo.subtype = null;
@@ -212,6 +212,7 @@ const createUrlInfo = (url, context) => {
212
212
 
213
213
  sourcemap: null,
214
214
  sourcemapIsWrong: false,
215
+ sourcemapReference: null,
215
216
 
216
217
  generatedUrl: null,
217
218
  sourcemapGeneratedUrl: null,
@@ -18,14 +18,10 @@ export const createUrlInfoTransformer = ({
18
18
  sourcemapsComment,
19
19
  sourcemapsSources,
20
20
  sourcemapsSourcesProtocol,
21
- sourcemapsSourcesContent,
21
+ sourcemapsSourcesContent = true,
22
22
  outDirectoryUrl,
23
23
  supervisor,
24
24
  }) => {
25
- if (sourcemapsSourcesContent === undefined) {
26
- sourcemapsSourcesContent = true;
27
- }
28
-
29
25
  const formatSourcemapSource =
30
26
  typeof sourcemapsSources === "function"
31
27
  ? (source, urlInfo) => {
@@ -84,6 +80,7 @@ export const createUrlInfoTransformer = ({
84
80
  urlInfo.content = undefined;
85
81
  urlInfo.sourcemap = null;
86
82
  urlInfo.sourcemapIsWrong = null;
83
+ urlInfo.sourcemapReference = null;
87
84
  };
88
85
 
89
86
  const setContentProperties = (
@@ -148,6 +145,10 @@ export const createUrlInfoTransformer = ({
148
145
  generatedUrlObject.searchParams.delete("js_module_fallback");
149
146
  generatedUrlObject.searchParams.delete("as_js_module");
150
147
  generatedUrlObject.searchParams.delete("as_js_classic");
148
+ generatedUrlObject.searchParams.delete("as_css_module");
149
+ generatedUrlObject.searchParams.delete("as_json_module");
150
+ generatedUrlObject.searchParams.delete("as_text_module");
151
+ generatedUrlObject.searchParams.delete("dynamic_import");
151
152
  const urlForSourcemap = generatedUrlObject.href;
152
153
  urlInfo.sourcemapGeneratedUrl = generateSourcemapFileUrl(urlForSourcemap);
153
154
 
@@ -174,6 +175,7 @@ export const createUrlInfoTransformer = ({
174
175
  specifierLine: line,
175
176
  specifierColumn: column,
176
177
  });
178
+ urlInfo.sourcemapReference = sourcemapReference;
177
179
  try {
178
180
  await sourcemapReference.urlInfo.cook();
179
181
  const sourcemapRaw = JSON.parse(sourcemapReference.urlInfo.content);
@@ -287,11 +289,11 @@ export const createUrlInfoTransformer = ({
287
289
  if (!contentIsInlined) {
288
290
  writeFileSync(new URL(generatedUrl), urlInfo.content);
289
291
  }
290
- const { sourcemapGeneratedUrl, sourcemap } = urlInfo;
291
- if (sourcemapGeneratedUrl && sourcemap) {
292
+ const { sourcemapGeneratedUrl, sourcemapReference } = urlInfo;
293
+ if (sourcemapGeneratedUrl && sourcemapReference) {
292
294
  writeFileSync(
293
295
  new URL(sourcemapGeneratedUrl),
294
- JSON.stringify(sourcemap, null, " "),
296
+ sourcemapReference.urlInfo.content,
295
297
  );
296
298
  }
297
299
  };
@@ -310,25 +312,28 @@ export const createUrlInfoTransformer = ({
310
312
  // in this scenarion we don't want to inject sourcemap reference
311
313
  // just update the content
312
314
 
313
- let sourcemapReference = null;
314
- for (const referenceToOther of urlInfo.referenceToOthersSet) {
315
- if (referenceToOther.type === "sourcemap_comment") {
316
- sourcemapReference = referenceToOther;
317
- break;
318
- }
319
- }
315
+ let sourcemapReference = urlInfo.sourcemapReference;
320
316
  if (!sourcemapReference) {
321
- sourcemapReference = urlInfo.dependencies.inject({
322
- trace: {
323
- message: `sourcemap comment placeholder`,
324
- url: urlInfo.url,
325
- },
326
- type: "sourcemap_comment",
327
- subtype: urlInfo.contentType === "text/javascript" ? "js" : "css",
328
- expectedType: "sourcemap",
329
- specifier: urlInfo.sourcemapGeneratedUrl,
330
- isInline: sourcemaps === "inline",
331
- });
317
+ for (const referenceToOther of urlInfo.referenceToOthersSet) {
318
+ if (referenceToOther.type === "sourcemap_comment") {
319
+ sourcemapReference = referenceToOther;
320
+ break;
321
+ }
322
+ }
323
+ if (!sourcemapReference) {
324
+ sourcemapReference = urlInfo.dependencies.inject({
325
+ trace: {
326
+ message: `sourcemap comment placeholder`,
327
+ url: urlInfo.url,
328
+ },
329
+ type: "sourcemap_comment",
330
+ subtype: urlInfo.contentType === "text/javascript" ? "js" : "css",
331
+ expectedType: "sourcemap",
332
+ specifier: urlInfo.sourcemapGeneratedUrl,
333
+ isInline: sourcemaps === "inline",
334
+ });
335
+ }
336
+ urlInfo.sourcemapReference = sourcemapReference;
332
337
  }
333
338
  const sourcemapUrlInfo = sourcemapReference.urlInfo;
334
339
  // It's possible urlInfo content to be modified after being finalized