@jsenv/core 28.3.4 → 28.3.5

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
@@ -16810,9 +16810,18 @@ const jsenvPluginHmr = () => {
16810
16810
  return urlObject.href;
16811
16811
  },
16812
16812
  transformUrlSearchParams: (reference, context) => {
16813
- const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl);
16813
+ if (reference.type === "package_json") {
16814
+ // maybe the if above shoulb be .isImplicit but it's just a detail anyway
16815
+ return null;
16816
+ }
16817
+
16818
+ if (context.reference && !context.reference.data.hmr) {
16819
+ // parent do not use hmr search param
16820
+ return null;
16821
+ }
16814
16822
 
16815
- if (!parentUrlInfo || !parentUrlInfo.data.hmr) {
16823
+ if (!context.reference && !reference.data.hmr) {
16824
+ // entry point do not use hmr search param
16816
16825
  return null;
16817
16826
  }
16818
16827
 
@@ -16999,7 +17008,7 @@ const jsenvPluginAutoreloadServer = ({
16999
17008
  event
17000
17009
  }) => {
17001
17010
  const onUrlInfo = urlInfo => {
17002
- const relativeUrl = formatUrlForClient(url);
17011
+ const relativeUrl = formatUrlForClient(urlInfo.url);
17003
17012
  const hotUpdate = propagateUpdate(urlInfo);
17004
17013
 
17005
17014
  if (hotUpdate.declined) {
@@ -17017,16 +17026,18 @@ const jsenvPluginAutoreloadServer = ({
17017
17026
  }
17018
17027
  };
17019
17028
 
17020
- urlGraph.urlInfoMap.forEach(urlInfo => {
17021
- if (urlInfo.url === url) {
17022
- onUrlInfo(urlInfo);
17023
- } else {
17024
- const urlWithoutSearch = asUrlWithoutSearch(urlInfo.url);
17029
+ const exactUrlInfo = urlGraph.getUrlInfo(url);
17025
17030
 
17026
- if (urlWithoutSearch === url) {
17027
- onUrlInfo(urlInfo);
17028
- }
17029
- }
17031
+ if (exactUrlInfo) {
17032
+ onUrlInfo(exactUrlInfo);
17033
+ }
17034
+
17035
+ urlGraph.urlInfoMap.forEach(urlInfo => {
17036
+ if (urlInfo === exactUrlInfo) return;
17037
+ const urlWithoutSearch = asUrlWithoutSearch(urlInfo.url);
17038
+ if (urlWithoutSearch !== url) return;
17039
+ if (exactUrlInfo && exactUrlInfo.dependents.has(urlInfo.url)) return;
17040
+ onUrlInfo(urlInfo);
17030
17041
  });
17031
17042
  });
17032
17043
  clientFilesPruneCallbackList.push((prunedUrlInfos, firstUrlInfo) => {
@@ -25309,16 +25320,22 @@ const createFileService = ({
25309
25320
  clientFileChangeCallbackList.push(({
25310
25321
  url
25311
25322
  }) => {
25312
- urlGraph.urlInfoMap.forEach(urlInfo => {
25313
- if (urlInfo.url === url) {
25314
- urlGraph.considerModified(urlInfo);
25315
- } else {
25316
- const urlWithoutSearch = asUrlWithoutSearch(urlInfo.url);
25323
+ const onUrlInfo = urlInfo => {
25324
+ urlGraph.considerModified(urlInfo);
25325
+ };
25317
25326
 
25318
- if (urlWithoutSearch === url) {
25319
- urlGraph.considerModified(urlInfo);
25320
- }
25321
- }
25327
+ const exactUrlInfo = urlGraph.getUrlInfo(url);
25328
+
25329
+ if (exactUrlInfo) {
25330
+ onUrlInfo(exactUrlInfo);
25331
+ }
25332
+
25333
+ urlGraph.urlInfoMap.forEach(urlInfo => {
25334
+ if (urlInfo === exactUrlInfo) return;
25335
+ const urlWithoutSearch = asUrlWithoutSearch(urlInfo.url);
25336
+ if (urlWithoutSearch !== url) return;
25337
+ if (exactUrlInfo && exactUrlInfo.dependents.has(urlInfo.url)) return;
25338
+ onUrlInfo(urlInfo);
25322
25339
  });
25323
25340
  });
25324
25341
  const kitchen = createKitchen({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "28.3.4",
3
+ "version": "28.3.5",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -95,15 +95,19 @@ export const createFileService = ({
95
95
  )
96
96
  const urlGraph = createUrlGraph()
97
97
  clientFileChangeCallbackList.push(({ url }) => {
98
+ const onUrlInfo = (urlInfo) => {
99
+ urlGraph.considerModified(urlInfo)
100
+ }
101
+ const exactUrlInfo = urlGraph.getUrlInfo(url)
102
+ if (exactUrlInfo) {
103
+ onUrlInfo(exactUrlInfo)
104
+ }
98
105
  urlGraph.urlInfoMap.forEach((urlInfo) => {
99
- if (urlInfo.url === url) {
100
- urlGraph.considerModified(urlInfo)
101
- } else {
102
- const urlWithoutSearch = asUrlWithoutSearch(urlInfo.url)
103
- if (urlWithoutSearch === url) {
104
- urlGraph.considerModified(urlInfo)
105
- }
106
- }
106
+ if (urlInfo === exactUrlInfo) return
107
+ const urlWithoutSearch = asUrlWithoutSearch(urlInfo.url)
108
+ if (urlWithoutSearch !== url) return
109
+ if (exactUrlInfo && exactUrlInfo.dependents.has(urlInfo.url)) return
110
+ onUrlInfo(urlInfo)
107
111
  })
108
112
  })
109
113
  const kitchen = createKitchen({
@@ -118,7 +118,7 @@ export const jsenvPluginAutoreloadServer = ({
118
118
  }
119
119
  clientFileChangeCallbackList.push(({ url, event }) => {
120
120
  const onUrlInfo = (urlInfo) => {
121
- const relativeUrl = formatUrlForClient(url)
121
+ const relativeUrl = formatUrlForClient(urlInfo.url)
122
122
  const hotUpdate = propagateUpdate(urlInfo)
123
123
  if (hotUpdate.declined) {
124
124
  notifyDeclined({
@@ -134,15 +134,16 @@ export const jsenvPluginAutoreloadServer = ({
134
134
  })
135
135
  }
136
136
  }
137
+ const exactUrlInfo = urlGraph.getUrlInfo(url)
138
+ if (exactUrlInfo) {
139
+ onUrlInfo(exactUrlInfo)
140
+ }
137
141
  urlGraph.urlInfoMap.forEach((urlInfo) => {
138
- if (urlInfo.url === url) {
139
- onUrlInfo(urlInfo)
140
- } else {
141
- const urlWithoutSearch = asUrlWithoutSearch(urlInfo.url)
142
- if (urlWithoutSearch === url) {
143
- onUrlInfo(urlInfo)
144
- }
145
- }
142
+ if (urlInfo === exactUrlInfo) return
143
+ const urlWithoutSearch = asUrlWithoutSearch(urlInfo.url)
144
+ if (urlWithoutSearch !== url) return
145
+ if (exactUrlInfo && exactUrlInfo.dependents.has(urlInfo.url)) return
146
+ onUrlInfo(urlInfo)
146
147
  })
147
148
  })
148
149
  clientFilesPruneCallbackList.push((prunedUrlInfos, firstUrlInfo) => {
@@ -7,7 +7,6 @@ export const jsenvPluginHmr = () => {
7
7
  reference.data.hmr = false
8
8
  return null
9
9
  }
10
-
11
10
  reference.data.hmr = true
12
11
  const urlObject = new URL(reference.url)
13
12
  // "hmr" search param goal is to mark url as enabling hmr:
@@ -19,8 +18,16 @@ export const jsenvPluginHmr = () => {
19
18
  return urlObject.href
20
19
  },
21
20
  transformUrlSearchParams: (reference, context) => {
22
- const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl)
23
- if (!parentUrlInfo || !parentUrlInfo.data.hmr) {
21
+ if (reference.type === "package_json") {
22
+ // maybe the if above shoulb be .isImplicit but it's just a detail anyway
23
+ return null
24
+ }
25
+ if (context.reference && !context.reference.data.hmr) {
26
+ // parent do not use hmr search param
27
+ return null
28
+ }
29
+ if (!context.reference && !reference.data.hmr) {
30
+ // entry point do not use hmr search param
24
31
  return null
25
32
  }
26
33
  const urlInfo = context.urlGraph.getUrlInfo(reference.url)