@jsenv/core 39.9.5 → 39.9.7

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.
@@ -1485,6 +1485,14 @@ const isValidUrl$1 = (url) => {
1485
1485
  }
1486
1486
  };
1487
1487
 
1488
+ const asSpecifierWithoutSearch = (specifier) => {
1489
+ if (isValidUrl$1(specifier)) {
1490
+ return asUrlWithoutSearch(specifier);
1491
+ }
1492
+ const [beforeQuestion] = specifier.split("?");
1493
+ return beforeQuestion;
1494
+ };
1495
+
1488
1496
  // normalize url search params:
1489
1497
  // Using URLSearchParams to alter the url search params
1490
1498
  // can result into "file:///file.css?css_module"
@@ -13085,6 +13093,7 @@ const createReference = ({
13085
13093
  );
13086
13094
  }
13087
13095
  }
13096
+
13088
13097
  const reference = {
13089
13098
  id: ++referenceId,
13090
13099
  ownerUrlInfo,
@@ -13107,6 +13116,9 @@ const createReference = ({
13107
13116
  integrity,
13108
13117
  crossorigin,
13109
13118
  specifier,
13119
+ get specifierPathname() {
13120
+ return asSpecifierWithoutSearch(reference.specifier);
13121
+ },
13110
13122
  specifierStart,
13111
13123
  specifierEnd,
13112
13124
  specifierLine,
@@ -14503,11 +14515,15 @@ const createUrlInfoTransformer = ({
14503
14515
  if (!generatedUrl.startsWith("file:")) {
14504
14516
  return;
14505
14517
  }
14506
- if (
14507
- urlInfo.type === "directory" ||
14508
- // happens when type is "html" to list directory content for example
14509
- urlInfo.firstReference?.fsStat?.isDirectory()
14510
- ) {
14518
+ if (urlToPathname$1(generatedUrl).endsWith("/")) {
14519
+ // when users explicitely request a directory
14520
+ // we can't write the content returned by the server in ".jsenv" at that url
14521
+ // because it would try to write a directory
14522
+ // ideally we would decide a filename for this
14523
+ // for now we just don't write anything
14524
+ return;
14525
+ }
14526
+ if (urlInfo.type === "directory") {
14511
14527
  // no need to write the directory
14512
14528
  return;
14513
14529
  }
@@ -15598,7 +15614,7 @@ const jsenvPluginDirectoryReferenceEffect = (
15598
15614
  reference.filenameHint = `${
15599
15615
  reference.ownerUrlInfo.filenameHint
15600
15616
  }${urlToFilename$1(reference.url)}/`;
15601
- } else if (reference.specifier.endsWith("./")) ; else {
15617
+ } else if (reference.specifierPathname.endsWith("./")) ; else {
15602
15618
  reference.filenameHint = `${urlToFilename$1(reference.url)}/`;
15603
15619
  }
15604
15620
  let actionForDirectory;
@@ -18886,7 +18902,7 @@ const createNodeEsmResolver = ({
18886
18902
  return reference.specifier;
18887
18903
  }
18888
18904
  const { ownerUrlInfo } = reference;
18889
- if (reference.specifier[0] === "/") {
18905
+ if (reference.specifierPathname[0] === "/") {
18890
18906
  const url = new URL(
18891
18907
  reference.specifier.slice(1),
18892
18908
  ownerUrlInfo.context.rootDirectoryUrl,
@@ -19088,7 +19104,7 @@ const jsenvPluginWebResolution = () => {
19088
19104
  appliesDuring: "*",
19089
19105
  resolveReference: (reference) => {
19090
19106
  const { ownerUrlInfo } = reference;
19091
- if (reference.specifier[0] === "/") {
19107
+ if (reference.specifierPathname[0] === "/") {
19092
19108
  const url = new URL(
19093
19109
  reference.specifier.slice(1),
19094
19110
  ownerUrlInfo.context.rootDirectoryUrl,
@@ -21129,7 +21145,7 @@ const getCorePlugins = ({
21129
21145
  appliesDuring: "*",
21130
21146
  resolveReference: (reference) => {
21131
21147
  const { ownerUrlInfo } = reference;
21132
- if (reference.specifier === "/") {
21148
+ if (reference.specifierPathname === "/") {
21133
21149
  const { mainFilePath, rootDirectoryUrl } = ownerUrlInfo.context;
21134
21150
  const url = new URL(mainFilePath, rootDirectoryUrl);
21135
21151
  return url;
@@ -21582,7 +21598,7 @@ const createBuildSpecifierManager = ({
21582
21598
  const url = new URL(reference.specifier, ownerRawUrl).href;
21583
21599
  return url;
21584
21600
  }
21585
- if (reference.specifier[0] === "/") {
21601
+ if (reference.specifierPathname[0] === "/") {
21586
21602
  const url = new URL(reference.specifier.slice(1), sourceDirectoryUrl)
21587
21603
  .href;
21588
21604
  return url;
@@ -21707,6 +21723,7 @@ const createBuildSpecifierManager = ({
21707
21723
  type: reference.type,
21708
21724
  expectedType: reference.expectedType,
21709
21725
  specifier: reference.specifier,
21726
+ specifierPathname: reference.specifierPathname,
21710
21727
  specifierLine: reference.specifierLine,
21711
21728
  specifierColumn: reference.specifierColumn,
21712
21729
  specifierStart: reference.specifierStart,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "39.9.5",
3
+ "version": "39.9.7",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -69,22 +69,22 @@
69
69
  "dependencies": {
70
70
  "@financial-times/polyfill-useragent-normaliser": "1.10.2",
71
71
  "@jsenv/abort": "4.3.0",
72
- "@jsenv/ast": "6.4.3",
73
- "@jsenv/filesystem": "4.13.1",
72
+ "@jsenv/ast": "6.4.4",
73
+ "@jsenv/filesystem": "4.13.2",
74
74
  "@jsenv/humanize": "1.2.8",
75
75
  "@jsenv/importmap": "1.2.1",
76
76
  "@jsenv/integrity": "0.0.2",
77
- "@jsenv/js-module-fallback": "1.3.55",
77
+ "@jsenv/js-module-fallback": "1.3.56",
78
78
  "@jsenv/node-esm-resolution": "1.0.6",
79
- "@jsenv/plugin-bundling": "2.7.23",
79
+ "@jsenv/plugin-bundling": "2.7.24",
80
80
  "@jsenv/plugin-minification": "1.5.13",
81
- "@jsenv/plugin-supervisor": "1.6.2",
82
- "@jsenv/plugin-transpilation": "1.4.91",
81
+ "@jsenv/plugin-supervisor": "1.6.3",
82
+ "@jsenv/plugin-transpilation": "1.4.92",
83
83
  "@jsenv/runtime-compat": "1.3.1",
84
84
  "@jsenv/server": "15.3.3",
85
- "@jsenv/sourcemap": "1.2.29",
85
+ "@jsenv/sourcemap": "1.2.30",
86
86
  "@jsenv/url-meta": "8.5.2",
87
- "@jsenv/urls": "2.5.4",
87
+ "@jsenv/urls": "2.6.0",
88
88
  "@jsenv/utils": "2.1.2",
89
89
  "string-width": "7.2.0"
90
90
  },
@@ -170,7 +170,7 @@ export const createBuildSpecifierManager = ({
170
170
  const url = new URL(reference.specifier, ownerRawUrl).href;
171
171
  return url;
172
172
  }
173
- if (reference.specifier[0] === "/") {
173
+ if (reference.specifierPathname[0] === "/") {
174
174
  const url = new URL(reference.specifier.slice(1), sourceDirectoryUrl)
175
175
  .href;
176
176
  return url;
@@ -295,6 +295,7 @@ export const createBuildSpecifierManager = ({
295
295
  type: reference.type,
296
296
  expectedType: reference.expectedType,
297
297
  specifier: reference.specifier,
298
+ specifierPathname: reference.specifierPathname,
298
299
  specifierLine: reference.specifierLine,
299
300
  specifierColumn: reference.specifierColumn,
300
301
  specifierStart: reference.specifierStart,
@@ -1,6 +1,7 @@
1
1
  import { generateUrlForInlineContent } from "@jsenv/ast";
2
2
  import { generateContentFrame } from "@jsenv/humanize";
3
3
  import {
4
+ asSpecifierWithoutSearch,
4
5
  getCallerPosition,
5
6
  stringifyUrlSite,
6
7
  urlToBasename,
@@ -315,6 +316,7 @@ const createReference = ({
315
316
  );
316
317
  }
317
318
  }
319
+
318
320
  const reference = {
319
321
  id: ++referenceId,
320
322
  ownerUrlInfo,
@@ -337,6 +339,9 @@ const createReference = ({
337
339
  integrity,
338
340
  crossorigin,
339
341
  specifier,
342
+ get specifierPathname() {
343
+ return asSpecifierWithoutSearch(reference.specifier);
344
+ },
340
345
  specifierStart,
341
346
  specifierEnd,
342
347
  specifierLine,
@@ -4,7 +4,7 @@ import {
4
4
  generateSourcemapDataUrl,
5
5
  SOURCEMAP,
6
6
  } from "@jsenv/sourcemap";
7
- import { isFileSystemPath, urlToRelativeUrl } from "@jsenv/urls";
7
+ import { isFileSystemPath, urlToPathname, urlToRelativeUrl } from "@jsenv/urls";
8
8
  import { pathToFileURL } from "node:url";
9
9
  import {
10
10
  defineGettersOnPropertiesDerivedFromContent,
@@ -251,11 +251,15 @@ export const createUrlInfoTransformer = ({
251
251
  if (!generatedUrl.startsWith("file:")) {
252
252
  return;
253
253
  }
254
- if (
255
- urlInfo.type === "directory" ||
256
- // happens when type is "html" to list directory content for example
257
- urlInfo.firstReference?.fsStat?.isDirectory()
258
- ) {
254
+ if (urlToPathname(generatedUrl).endsWith("/")) {
255
+ // when users explicitely request a directory
256
+ // we can't write the content returned by the server in ".jsenv" at that url
257
+ // because it would try to write a directory
258
+ // ideally we would decide a filename for this
259
+ // for now we just don't write anything
260
+ return;
261
+ }
262
+ if (urlInfo.type === "directory") {
259
263
  // no need to write the directory
260
264
  return;
261
265
  }
@@ -30,7 +30,7 @@ export const jsenvPluginDirectoryReferenceEffect = (
30
30
  reference.filenameHint = `${
31
31
  reference.ownerUrlInfo.filenameHint
32
32
  }${urlToFilename(reference.url)}/`;
33
- } else if (reference.specifier.endsWith("./")) {
33
+ } else if (reference.specifierPathname.endsWith("./")) {
34
34
  } else {
35
35
  reference.filenameHint = `${urlToFilename(reference.url)}/`;
36
36
  }
@@ -86,7 +86,7 @@ export const getCorePlugins = ({
86
86
  appliesDuring: "*",
87
87
  resolveReference: (reference) => {
88
88
  const { ownerUrlInfo } = reference;
89
- if (reference.specifier === "/") {
89
+ if (reference.specifierPathname === "/") {
90
90
  const { mainFilePath, rootDirectoryUrl } = ownerUrlInfo.context;
91
91
  const url = new URL(mainFilePath, rootDirectoryUrl);
92
92
  return url;
@@ -33,7 +33,7 @@ export const createNodeEsmResolver = ({
33
33
  return reference.specifier;
34
34
  }
35
35
  const { ownerUrlInfo } = reference;
36
- if (reference.specifier[0] === "/") {
36
+ if (reference.specifierPathname[0] === "/") {
37
37
  const url = new URL(
38
38
  reference.specifier.slice(1),
39
39
  ownerUrlInfo.context.rootDirectoryUrl,
@@ -4,7 +4,7 @@ export const jsenvPluginWebResolution = () => {
4
4
  appliesDuring: "*",
5
5
  resolveReference: (reference) => {
6
6
  const { ownerUrlInfo } = reference;
7
- if (reference.specifier[0] === "/") {
7
+ if (reference.specifierPathname[0] === "/") {
8
8
  const url = new URL(
9
9
  reference.specifier.slice(1),
10
10
  ownerUrlInfo.context.rootDirectoryUrl,