@jsenv/core 25.1.1 → 25.3.0

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.
Files changed (57) hide show
  1. package/dist/browser_runtime/browser_runtime_91c5a3b8.js.map +2 -2
  2. package/dist/build_manifest.js +4 -4
  3. package/dist/compile_proxy/asset-manifest.json +2 -2
  4. package/dist/compile_proxy/{compile_proxy_e3b0c442_809f35f7.js.map → compile_proxy.html__inline__20_809f35f7.js.map} +0 -0
  5. package/dist/compile_proxy/{compile_proxy_7ad5faa6.html → compile_proxy_8dfaee51.html} +3 -4
  6. package/dist/redirector/asset-manifest.json +2 -2
  7. package/dist/redirector/{redirector_e3b0c442_e391410e.js.map → redirector.html__inline__15_e391410e.js.map} +0 -0
  8. package/dist/redirector/{redirector_eb92e8a7.html → redirector_3e9a97b9.html} +3 -4
  9. package/dist/toolbar/asset-manifest.json +1 -1
  10. package/dist/toolbar/{toolbar_f7b8a263.html → toolbar_361afb84.html} +2 -3
  11. package/dist/toolbar_injector/asset-manifest.json +2 -2
  12. package/dist/toolbar_injector/{toolbar_injector_49e4756e.js → toolbar_injector_fac1e995.js} +2 -2
  13. package/dist/toolbar_injector/{toolbar_injector_49e4756e.js.map → toolbar_injector_fac1e995.js.map} +2 -2
  14. package/package.json +13 -9
  15. package/readme.md +73 -79
  16. package/src/buildProject.js +21 -13
  17. package/src/commonJsToJavaScriptModule.js +8 -7
  18. package/src/dev_server.js +2 -0
  19. package/src/execute.js +2 -0
  20. package/src/executeTestPlan.js +4 -1
  21. package/src/internal/building/buildUsingRollup.js +4 -2
  22. package/src/internal/building/build_stats.js +3 -0
  23. package/src/internal/building/build_url_generator.js +153 -0
  24. package/src/internal/building/css/parseCssRessource.js +32 -26
  25. package/src/internal/building/html/parseHtmlRessource.js +93 -68
  26. package/src/internal/building/js/parseJsRessource.js +4 -7
  27. package/src/internal/building/parseRessource.js +3 -0
  28. package/src/internal/building/ressource_builder.js +64 -62
  29. package/src/internal/building/ressource_builder_util.js +17 -5
  30. package/src/internal/building/rollup_plugin_jsenv.js +259 -189
  31. package/src/internal/building/url_fetcher.js +16 -7
  32. package/src/internal/building/url_loader.js +1 -5
  33. package/src/internal/building/url_versioning.js +0 -173
  34. package/src/internal/compiling/babel_plugin_import_metadata.js +7 -11
  35. package/src/internal/compiling/babel_plugin_proxy_external_imports.js +31 -0
  36. package/src/internal/compiling/compile-directory/compile-asset.js +8 -4
  37. package/src/internal/compiling/compile-directory/getOrGenerateCompiledFile.js +43 -8
  38. package/src/internal/compiling/compile-directory/updateMeta.js +4 -8
  39. package/src/internal/compiling/compile-directory/validateCache.js +1 -2
  40. package/src/internal/compiling/compileFile.js +22 -10
  41. package/src/internal/compiling/createCompiledFileService.js +22 -24
  42. package/src/internal/compiling/html_source_file_service.js +9 -9
  43. package/src/internal/compiling/js-compilation-service/babelHelper.js +10 -13
  44. package/src/internal/compiling/js-compilation-service/babel_plugin_babel_helpers_as_jsenv_imports.js +4 -2
  45. package/src/internal/compiling/js-compilation-service/jsenvTransform.js +16 -7
  46. package/src/internal/compiling/js-compilation-service/transformJs.js +9 -5
  47. package/src/internal/compiling/jsenvCompilerForHtml.js +226 -184
  48. package/src/internal/compiling/jsenvCompilerForJavaScript.js +15 -11
  49. package/src/internal/compiling/startCompileServer.js +79 -19
  50. package/src/internal/compiling/transformResultToCompilationResult.js +47 -25
  51. package/src/internal/executing/executePlan.js +2 -0
  52. package/src/internal/fetchUrl.js +3 -2
  53. package/src/internal/jsenv_remote_directory.js +156 -0
  54. package/src/internal/origin_directory_converter.js +62 -0
  55. package/src/internal/response_validation.js +11 -24
  56. package/src/internal/sourceMappingURLUtils.js +10 -0
  57. package/src/internal/url_conversion.js +1 -0
@@ -10,7 +10,6 @@ export const validateResponse = async (
10
10
  } = {},
11
11
  ) => {
12
12
  const validity = { isValid: true }
13
-
14
13
  if (statusValidation) {
15
14
  const statusValidity = await checkStatus(response, {
16
15
  originalUrl,
@@ -21,7 +20,6 @@ export const validateResponse = async (
21
20
  return validity
22
21
  }
23
22
  }
24
-
25
23
  if (contentTypeExpected) {
26
24
  const contentTypeValidity = await checkContentType(response, {
27
25
  originalUrl,
@@ -33,7 +31,6 @@ export const validateResponse = async (
33
31
  return validity
34
32
  }
35
33
  }
36
-
37
34
  return validity
38
35
  }
39
36
 
@@ -47,36 +44,28 @@ const mergeValidity = (parentValidity, childValidityName, childValidity) => {
47
44
  const checkStatus = async (response, { originalUrl, urlTrace }) => {
48
45
  const url = originalUrl || response.url
49
46
  const { status } = response
50
-
51
- if (status === 500) {
52
- if (response.headers["content-type"] === "application/json") {
53
- return {
54
- isValid: false,
55
- message: `error 500 on url`,
56
- details: {
57
- "response status": status,
58
- "response json": JSON.stringify(await response.json(), null, " "),
59
- url,
60
- ...formatUrlTrace(urlTrace),
61
- },
62
- }
63
- }
64
- }
65
-
66
47
  if (status < 200 || status > 299) {
67
- const responseText = await response.text()
68
48
  return {
69
49
  isValid: false,
70
50
  message: `invalid response status on url`,
71
51
  details: {
72
52
  "response status": status,
73
- ...(responseText ? { "response text": responseText } : {}),
74
53
  url,
75
54
  ...formatUrlTrace(urlTrace),
55
+ ...(response.headers["content-type"] === "application/json"
56
+ ? {
57
+ "response text": JSON.stringify(
58
+ await response.json(),
59
+ null,
60
+ " ",
61
+ ),
62
+ }
63
+ : {
64
+ "response text": await response.text(),
65
+ }),
76
66
  },
77
67
  }
78
68
  }
79
-
80
69
  return { isValid: true }
81
70
  }
82
71
 
@@ -86,11 +75,9 @@ const checkContentType = async (
86
75
  ) => {
87
76
  const url = originalUrl || response.url
88
77
  const responseContentType = response.headers["content-type"] || ""
89
-
90
78
  const isOk = Array.isArray(contentTypeExpected)
91
79
  ? contentTypeExpected.includes(responseContentType)
92
80
  : responseContentType === contentTypeExpected
93
-
94
81
  if (!isOk) {
95
82
  return {
96
83
  isValid: false,
@@ -1,3 +1,13 @@
1
+ export const generateSourcemapUrl = (url) => {
2
+ // we want to remove eventual search params from url
3
+ const urlString = String(url)
4
+ const urlObject = new URL(url)
5
+ const origin = urlString.startsWith("file://") ? "file://" : urlObject.origin
6
+ const pathname = urlObject.pathname
7
+ const sourcemapUrl = `${origin}${pathname}.map`
8
+ return sourcemapUrl
9
+ }
10
+
1
11
  export const getJavaScriptSourceMappingUrl = (javaScriptSource) => {
2
12
  let sourceMappingUrl
3
13
  replaceSourceMappingUrl(
@@ -124,6 +124,7 @@ export const createUrlConverter = ({
124
124
  }
125
125
 
126
126
  return {
127
+ compileServerOriginForRollup,
127
128
  asRollupUrl,
128
129
  asProjectUrl,
129
130
  asServerUrl,