@jsenv/core 27.0.2 → 27.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.
package/dist/main.js CHANGED
@@ -21446,6 +21446,7 @@ const createUrlInfo = url => {
21446
21446
  content: undefined,
21447
21447
  sourcemap: null,
21448
21448
  sourcemapReference: null,
21449
+ sourcemapIsWrong: false,
21449
21450
  timing: {},
21450
21451
  headers: {}
21451
21452
  };
@@ -21891,7 +21892,8 @@ const createUrlInfoTransformer = ({
21891
21892
  type,
21892
21893
  contentType,
21893
21894
  content,
21894
- sourcemap
21895
+ sourcemap,
21896
+ sourcemapIsWrong
21895
21897
  } = transformations;
21896
21898
 
21897
21899
  if (type) {
@@ -21910,7 +21912,17 @@ const createUrlInfoTransformer = ({
21910
21912
  const sourcemapNormalized = normalizeSourcemap(urlInfo, sourcemap);
21911
21913
  const finalSourcemap = await composeTwoSourcemaps(urlInfo.sourcemap, sourcemapNormalized);
21912
21914
  const finalSourcemapNormalized = normalizeSourcemap(urlInfo, finalSourcemap);
21913
- urlInfo.sourcemap = finalSourcemapNormalized;
21915
+ urlInfo.sourcemap = finalSourcemapNormalized; // A plugin is allowed to modify url content
21916
+ // without returning a sourcemap
21917
+ // This is the case for preact and react plugins.
21918
+ // They are currently generating wrong source mappings
21919
+ // when used.
21920
+ // Generating the correct sourcemap in this situation
21921
+ // is a nightmare no-one could solve in years so
21922
+ // jsenv won't emit a warning and use the following strategy:
21923
+ // "no sourcemap is better than wrong sourcemap"
21924
+
21925
+ urlInfo.sourcemapIsWrong = sourcemapIsWrong;
21914
21926
  }
21915
21927
  };
21916
21928
 
@@ -21939,16 +21951,18 @@ const createUrlInfoTransformer = ({
21939
21951
 
21940
21952
  sourcemapUrlInfo.content = JSON.stringify(sourcemap, null, " ");
21941
21953
 
21942
- if (sourcemaps === "inline") {
21943
- sourcemapReference.generatedSpecifier = generateSourcemapDataUrl(sourcemap);
21944
- }
21954
+ if (!urlInfo.sourcemapIsWrong) {
21955
+ if (sourcemaps === "inline") {
21956
+ sourcemapReference.generatedSpecifier = generateSourcemapDataUrl(sourcemap);
21957
+ }
21945
21958
 
21946
- if (sourcemaps === "file" || sourcemaps === "inline") {
21947
- urlInfo.content = SOURCEMAP.writeComment({
21948
- contentType: urlInfo.contentType,
21949
- content: urlInfo.content,
21950
- specifier: sourcemaps === "file" && sourcemapsRelativeSources ? urlToRelativeUrl(sourcemapReference.url, urlInfo.url) : sourcemapReference.generatedSpecifier
21951
- });
21959
+ if (sourcemaps === "file" || sourcemaps === "inline") {
21960
+ urlInfo.content = SOURCEMAP.writeComment({
21961
+ contentType: urlInfo.contentType,
21962
+ content: urlInfo.content,
21963
+ specifier: sourcemaps === "file" && sourcemapsRelativeSources ? urlToRelativeUrl(sourcemapReference.url, urlInfo.url) : sourcemapReference.generatedSpecifier
21964
+ });
21965
+ }
21952
21966
  }
21953
21967
  } else if (urlInfo.sourcemapReference) {
21954
21968
  // in the end we don't use the sourcemap placeholder
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "27.0.2",
3
+ "version": "27.0.3",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -60,9 +60,9 @@
60
60
  "playwright": "1.x"
61
61
  },
62
62
  "dependencies": {
63
- "@babel/plugin-proposal-dynamic-import": "7.16.7",
63
+ "@babel/plugin-proposal-dynamic-import": "7.18.6",
64
64
  "@babel/plugin-transform-modules-systemjs": "7.18.6",
65
- "@babel/plugin-transform-modules-umd": "7.18.0",
65
+ "@babel/plugin-transform-modules-umd": "7.18.6",
66
66
  "@c88/v8-coverage": "0.1.1",
67
67
  "@financial-times/polyfill-useragent-normaliser": "2.0.1",
68
68
  "@jsenv/ast": "1.1.1",
@@ -96,9 +96,9 @@
96
96
  },
97
97
  "devDependencies": {
98
98
  "@babel/eslint-parser": "7.18.2",
99
- "@babel/plugin-syntax-import-assertions": "7.17.12",
99
+ "@babel/plugin-syntax-import-assertions": "7.18.6",
100
100
  "@jsenv/assert": "2.6.0",
101
- "@jsenv/eslint-config": "16.0.9",
101
+ "@jsenv/eslint-config": "16.1.0",
102
102
  "@jsenv/file-size-impact": "13.0.1",
103
103
  "@jsenv/https-local": "2.1.0",
104
104
  "@jsenv/package-workspace": "0.4.1",
@@ -117,7 +117,8 @@ export const createUrlInfoTransformer = ({
117
117
  if (!transformations) {
118
118
  return
119
119
  }
120
- const { type, contentType, content, sourcemap } = transformations
120
+ const { type, contentType, content, sourcemap, sourcemapIsWrong } =
121
+ transformations
121
122
  if (type) {
122
123
  urlInfo.type = type
123
124
  }
@@ -138,6 +139,16 @@ export const createUrlInfoTransformer = ({
138
139
  finalSourcemap,
139
140
  )
140
141
  urlInfo.sourcemap = finalSourcemapNormalized
142
+ // A plugin is allowed to modify url content
143
+ // without returning a sourcemap
144
+ // This is the case for preact and react plugins.
145
+ // They are currently generating wrong source mappings
146
+ // when used.
147
+ // Generating the correct sourcemap in this situation
148
+ // is a nightmare no-one could solve in years so
149
+ // jsenv won't emit a warning and use the following strategy:
150
+ // "no sourcemap is better than wrong sourcemap"
151
+ urlInfo.sourcemapIsWrong = sourcemapIsWrong
141
152
  }
142
153
  }
143
154
 
@@ -162,19 +173,21 @@ export const createUrlInfoTransformer = ({
162
173
  })
163
174
  }
164
175
  sourcemapUrlInfo.content = JSON.stringify(sourcemap, null, " ")
165
- if (sourcemaps === "inline") {
166
- sourcemapReference.generatedSpecifier =
167
- generateSourcemapDataUrl(sourcemap)
168
- }
169
- if (sourcemaps === "file" || sourcemaps === "inline") {
170
- urlInfo.content = SOURCEMAP.writeComment({
171
- contentType: urlInfo.contentType,
172
- content: urlInfo.content,
173
- specifier:
174
- sourcemaps === "file" && sourcemapsRelativeSources
175
- ? urlToRelativeUrl(sourcemapReference.url, urlInfo.url)
176
- : sourcemapReference.generatedSpecifier,
177
- })
176
+ if (!urlInfo.sourcemapIsWrong) {
177
+ if (sourcemaps === "inline") {
178
+ sourcemapReference.generatedSpecifier =
179
+ generateSourcemapDataUrl(sourcemap)
180
+ }
181
+ if (sourcemaps === "file" || sourcemaps === "inline") {
182
+ urlInfo.content = SOURCEMAP.writeComment({
183
+ contentType: urlInfo.contentType,
184
+ content: urlInfo.content,
185
+ specifier:
186
+ sourcemaps === "file" && sourcemapsRelativeSources
187
+ ? urlToRelativeUrl(sourcemapReference.url, urlInfo.url)
188
+ : sourcemapReference.generatedSpecifier,
189
+ })
190
+ }
178
191
  }
179
192
  } else if (urlInfo.sourcemapReference) {
180
193
  // in the end we don't use the sourcemap placeholder
@@ -215,6 +215,7 @@ const createUrlInfo = (url) => {
215
215
 
216
216
  sourcemap: null,
217
217
  sourcemapReference: null,
218
+ sourcemapIsWrong: false,
218
219
  timing: {},
219
220
  headers: {},
220
221
  }