@jsenv/core 27.0.0-alpha.52 → 27.0.0-alpha.53

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "27.0.0-alpha.52",
3
+ "version": "27.0.0-alpha.53",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -618,6 +618,7 @@ ${Object.keys(rawGraph.urlInfos).join("\n")}`,
618
618
  urlGraph: finalGraph,
619
619
  kitchen: finalGraphKitchen,
620
620
  outDirectoryUrl: new URL(".jsenv/postbuild/", rootDirectoryUrl),
621
+ skipRessourceHint: true,
621
622
  startLoading: (cookEntryFile) => {
622
623
  entryUrls.forEach((entryUrl) => {
623
624
  const [, postBuildEntryUrlInfo] = cookEntryFile({
@@ -698,7 +699,7 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
698
699
  urlInfo.dependents.size === 0
699
700
  ) {
700
701
  cleanupActions.push(() => {
701
- delete finalGraph.urlInfos[urlInfo.url]
702
+ finalGraph.deleteUrlInfo(urlInfo.url)
702
703
  })
703
704
  }
704
705
  })
@@ -969,6 +970,7 @@ const applyUrlVersioning = async ({
969
970
  await loadUrlGraph({
970
971
  urlGraph: finalGraph,
971
972
  kitchen: versioningKitchen,
973
+ skipRessourceHint: true,
972
974
  startLoading: (cookEntryFile) => {
973
975
  postBuildEntryUrls.forEach((postBuildEntryUrl) => {
974
976
  cookEntryFile({
@@ -56,8 +56,8 @@ export const createBuilUrlsGenerator = ({ buildDirectoryUrl }) => {
56
56
  // To keep in mind: if you have "user.jsx" and "user.js" AND both file are not bundled
57
57
  // you end up with "dist/js/user.js" and "dist/js/user2.js"
58
58
  const extensionMappings = {
59
- ".ts": ".js",
60
59
  ".jsx": ".js",
60
+ ".ts": ".js",
61
61
  ".tsx": ".js",
62
62
  }
63
63
 
@@ -164,6 +164,12 @@ export const createKitchen = ({
164
164
  if (returnValue === reference.url) {
165
165
  return
166
166
  }
167
+ const normalizedReturnValue = returnValue.startsWith("data:")
168
+ ? returnValue
169
+ : returnValue.replace(/[=](?=&|$)/g, "")
170
+ if (normalizedReturnValue === reference.url) {
171
+ return
172
+ }
167
173
  const previousReference = { ...reference }
168
174
  reference.url = returnValue
169
175
  mutateReference(previousReference, reference)
@@ -6,6 +6,7 @@ export const loadUrlGraph = async ({
6
6
  startLoading,
7
7
  outDirectoryUrl,
8
8
  clientRuntimeCompat,
9
+ skipRessourceHint = false,
9
10
  }) => {
10
11
  if (outDirectoryUrl) {
11
12
  await ensureEmptyDirectory(outDirectoryUrl)
@@ -33,6 +34,9 @@ export const loadUrlGraph = async ({
33
34
  })
34
35
  const { references } = urlInfo
35
36
  references.forEach((reference) => {
37
+ if (skipRessourceHint && reference.isRessourceHint) {
38
+ return
39
+ }
36
40
  // we use reference.generatedUrl to mimic what a browser would do:
37
41
  // do a fetch to the specifier as found in the file
38
42
  const referencedUrlInfo = urlGraph.reuseOrCreateUrlInfo(
@@ -274,8 +274,9 @@ const getOriginalName = (path, name) => {
274
274
  return getOriginalName(path, importedName)
275
275
  }
276
276
  if (binding.path.type === "VariableDeclarator") {
277
- if (binding.path.node.init.type === "Identifier") {
278
- const previousName = binding.path.node.init.name
277
+ const { init } = binding.path.node
278
+ if (init && init.type === "Identifier") {
279
+ const previousName = init.name
279
280
  return getOriginalName(path, previousName)
280
281
  }
281
282
  }
@@ -119,7 +119,15 @@ const asJsClassic = ({ systemJsInjection, systemJsClientFileUrl }) => {
119
119
 
120
120
  const generateJsClassicFilename = (url) => {
121
121
  const filename = urlToFilename(url)
122
- const [basename, extension] = splitFileExtension(filename)
122
+ let [basename, extension] = splitFileExtension(filename)
123
+ const { searchParams } = new URL(url)
124
+ if (
125
+ searchParams.has("as_json_module") ||
126
+ searchParams.has("as_css_module") ||
127
+ searchParams.has("as_text_module")
128
+ ) {
129
+ extension = ".js"
130
+ }
123
131
  return `${basename}.es5${extension}`
124
132
  }
125
133
 
@@ -27,10 +27,10 @@ export const jsenvPluginImportAssertions = () => {
27
27
  end: reference.assertNode.end,
28
28
  })
29
29
  }
30
-
31
- return injectQueryParams(reference.url, {
30
+ const newUrl = injectQueryParams(reference.url, {
32
31
  [searchParam]: "",
33
32
  })
33
+ return newUrl
34
34
  }
35
35
 
36
36
  const importAssertions = {