@jsenv/core 27.0.0-alpha.64 → 27.0.0-alpha.67

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 (151) hide show
  1. package/dist/babel_helpers/AsyncGenerator/AsyncGenerator.js +95 -0
  2. package/dist/babel_helpers/AwaitValue/AwaitValue.js +3 -0
  3. package/dist/babel_helpers/applyDecoratorDescriptor/applyDecoratorDescriptor.js +29 -0
  4. package/dist/babel_helpers/arrayLikeToArray/arrayLikeToArray.js +9 -0
  5. package/dist/babel_helpers/arrayWithHoles/arrayWithHoles.js +4 -0
  6. package/dist/babel_helpers/arrayWithoutHoles/arrayWithoutHoles.js +5 -0
  7. package/dist/babel_helpers/assertThisInitialized/assertThisInitialized.js +8 -0
  8. package/dist/babel_helpers/asyncGeneratorDelegate/asyncGeneratorDelegate.js +52 -0
  9. package/dist/babel_helpers/asyncIterator/asyncIterator.js +78 -0
  10. package/dist/babel_helpers/asyncToGenerator/asyncToGenerator.js +39 -0
  11. package/dist/babel_helpers/awaitAsyncGenerator/awaitAsyncGenerator.js +4 -0
  12. package/dist/babel_helpers/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +24 -0
  13. package/dist/babel_helpers/classApplyDescriptorGet/classApplyDescriptorGet.js +7 -0
  14. package/dist/babel_helpers/classApplyDescriptorSet/classApplyDescriptorSet.js +14 -0
  15. package/dist/babel_helpers/classCallCheck/classCallCheck.js +5 -0
  16. package/dist/babel_helpers/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +5 -0
  17. package/dist/babel_helpers/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +6 -0
  18. package/dist/babel_helpers/classExtractFieldDescriptor/classExtractFieldDescriptor.js +8 -0
  19. package/dist/babel_helpers/classNameTDZError/classNameTDZError.js +4 -0
  20. package/dist/babel_helpers/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +6 -0
  21. package/dist/babel_helpers/classPrivateFieldGet/classPrivateFieldGet.js +6 -0
  22. package/dist/babel_helpers/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +7 -0
  23. package/dist/babel_helpers/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +5 -0
  24. package/dist/babel_helpers/classPrivateFieldSet/classPrivateFieldSet.js +7 -0
  25. package/dist/babel_helpers/classPrivateMethodGet/classPrivateMethodGet.js +7 -0
  26. package/dist/babel_helpers/classPrivateMethodSet/classPrivateMethodSet.js +3 -0
  27. package/dist/babel_helpers/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +8 -0
  28. package/dist/babel_helpers/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +9 -0
  29. package/dist/babel_helpers/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +5 -0
  30. package/dist/babel_helpers/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +3 -0
  31. package/dist/babel_helpers/construct/construct.js +15 -0
  32. package/dist/babel_helpers/createClass/createClass.js +18 -0
  33. package/dist/babel_helpers/createForOfIteratorHelper/createForOfIteratorHelper.js +63 -0
  34. package/dist/babel_helpers/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +22 -0
  35. package/dist/babel_helpers/createRawReactElement/createRawReactElement.js +50 -0
  36. package/dist/babel_helpers/createSuper/createSuper.js +22 -0
  37. package/dist/babel_helpers/decorate/decorate.js +622 -0
  38. package/dist/babel_helpers/defaults/defaults.js +14 -0
  39. package/dist/babel_helpers/defineEnumerableProperties/defineEnumerableProperties.js +26 -0
  40. package/dist/babel_helpers/defineProperty/defineProperty.js +19 -0
  41. package/dist/babel_helpers/extends/extends.js +16 -0
  42. package/dist/babel_helpers/get/get.js +21 -0
  43. package/dist/babel_helpers/getPrototypeOf/getPrototypeOf.js +2 -0
  44. package/dist/babel_helpers/inherits/inherits.js +21 -0
  45. package/dist/babel_helpers/inheritsLoose/inheritsLoose.js +6 -0
  46. package/dist/babel_helpers/initializerDefineProperty/initializerDefineProperty.js +10 -0
  47. package/dist/babel_helpers/initializerWarningHelper/initializerWarningHelper.js +3 -0
  48. package/dist/babel_helpers/instanceof/instanceof.js +7 -0
  49. package/dist/babel_helpers/interopRequireDefault/interopRequireDefault.js +5 -0
  50. package/dist/babel_helpers/interopRequireWildcard/interopRequireWildcard.js +49 -0
  51. package/dist/babel_helpers/isNativeFunction/isNativeFunction.js +4 -0
  52. package/dist/babel_helpers/isNativeReflectConstruct/isNativeReflectConstruct.js +21 -0
  53. package/dist/babel_helpers/iterableToArray/iterableToArray.js +3 -0
  54. package/dist/babel_helpers/iterableToArrayLimit/iterableToArrayLimit.js +38 -0
  55. package/dist/babel_helpers/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +13 -0
  56. package/dist/babel_helpers/jsx/jsx.js +49 -0
  57. package/dist/babel_helpers/maybeArrayLike/maybeArrayLike.js +10 -0
  58. package/dist/babel_helpers/newArrowCheck/newArrowCheck.js +5 -0
  59. package/dist/babel_helpers/nonIterableRest/nonIterableRest.js +3 -0
  60. package/dist/babel_helpers/nonIterableSpread/nonIterableSpread.js +3 -0
  61. package/dist/babel_helpers/objectDestructuringEmpty/objectDestructuringEmpty.js +3 -0
  62. package/dist/babel_helpers/objectSpread/objectSpread.js +22 -0
  63. package/dist/babel_helpers/objectSpread2/objectSpread2.js +41 -0
  64. package/dist/babel_helpers/objectWithoutProperties/objectWithoutProperties.js +20 -0
  65. package/dist/babel_helpers/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +15 -0
  66. package/dist/babel_helpers/possibleConstructorReturn/possibleConstructorReturn.js +10 -0
  67. package/dist/babel_helpers/readOnlyError/readOnlyError.js +4 -0
  68. package/dist/babel_helpers/readme.md +8 -0
  69. package/dist/babel_helpers/set/set.js +51 -0
  70. package/dist/babel_helpers/setPrototypeOf/setPrototypeOf.js +5 -0
  71. package/dist/babel_helpers/skipFirstGeneratorNext/skipFirstGeneratorNext.js +8 -0
  72. package/dist/babel_helpers/slicedToArray/slicedToArray.js +5 -0
  73. package/dist/babel_helpers/slicedToArrayLoose/slicedToArrayLoose.js +7 -0
  74. package/dist/babel_helpers/superPropBase/superPropBase.js +10 -0
  75. package/dist/babel_helpers/taggedTemplateLiteral/taggedTemplateLiteral.js +11 -0
  76. package/dist/babel_helpers/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +8 -0
  77. package/dist/babel_helpers/tdz/tdz.js +4 -0
  78. package/dist/babel_helpers/temporalRef/temporalRef.js +5 -0
  79. package/dist/babel_helpers/temporalUndefined/temporalUndefined.js +3 -0
  80. package/dist/babel_helpers/toArray/toArray.js +5 -0
  81. package/dist/babel_helpers/toConsumableArray/toConsumableArray.js +5 -0
  82. package/dist/babel_helpers/toPrimitive/toPrimitive.js +14 -0
  83. package/dist/babel_helpers/toPropertyKey/toPropertyKey.js +5 -0
  84. package/dist/babel_helpers/typeof/typeof.js +7 -0
  85. package/dist/babel_helpers/unsupportedIterableToArray/unsupportedIterableToArray.js +10 -0
  86. package/dist/babel_helpers/wrapAsyncGenerator/wrapAsyncGenerator.js +7 -0
  87. package/dist/babel_helpers/wrapNativeSuper/wrapNativeSuper.js +35 -0
  88. package/dist/babel_helpers/wrapRegExp/wrapRegExp.js +67 -0
  89. package/dist/babel_helpers/writeOnlyError/writeOnlyError.js +4 -0
  90. package/dist/html/explorer.html +557 -0
  91. package/dist/js/controllable_file.mjs +227 -0
  92. package/dist/{event_source_client.js → js/event_source_client.js} +19 -244
  93. package/dist/js/global_this.js +32 -0
  94. package/dist/js/html_supervisor_installer.js +522 -0
  95. package/dist/js/html_supervisor_setup.js +79 -0
  96. package/dist/{import_meta_hot.js → js/import_meta_hot.js} +1 -3
  97. package/dist/js/inline_content.js +8 -0
  98. package/dist/js/new_stylesheet.js +409 -0
  99. package/dist/js/regenerator_runtime.js +721 -0
  100. package/dist/js/s.js +429 -0
  101. package/dist/main.js +13450 -0
  102. package/dist/other/jsenv.png +0 -0
  103. package/dist/s.js.map +59 -62
  104. package/package.json +16 -12
  105. package/src/build/build.js +169 -68
  106. package/src/build/build_urls_generator.js +18 -2
  107. package/src/build/inject_service_worker_urls.js +1 -1
  108. package/src/build/resync_ressource_hints.js +56 -9
  109. package/src/dev/plugins/explorer/client/explorer.html +1 -1
  110. package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +1 -1
  111. package/src/dev/start_dev_server.js +17 -3
  112. package/src/execute/execute.js +3 -0
  113. package/src/omega/errors.js +12 -9
  114. package/src/omega/kitchen.js +252 -217
  115. package/src/omega/server/file_service.js +1 -1
  116. package/src/omega/url_graph/url_graph_report.js +2 -2
  117. package/src/omega/url_graph/url_info_transformations.js +10 -5
  118. package/src/omega/url_graph.js +3 -2
  119. package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_client.js +5 -10
  120. package/src/plugins/autoreload/jsenv_plugin_autoreload.js +1 -3
  121. package/src/plugins/bundling/js_module/bundle_js_module.js +66 -24
  122. package/src/plugins/file_urls/jsenv_plugin_file_urls.js +185 -53
  123. package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +9 -13
  124. package/src/plugins/http_urls/jsenv_plugin_http_urls.js +6 -6
  125. package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +5 -10
  126. package/src/plugins/inline/jsenv_plugin_js_inline_content.js +2 -2
  127. package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +12 -2
  128. package/src/plugins/node_runtime/jsenv_plugin_node_runtime.js +12 -0
  129. package/src/plugins/plugin_controller.js +17 -3
  130. package/src/plugins/plugins.js +16 -19
  131. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +17 -19
  132. package/src/plugins/transpilation/as_js_classic/{jsenv_plugin_script_type_module_as_classic.js → jsenv_plugin_as_js_classic_html.js} +0 -0
  133. package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +9 -4
  134. package/src/plugins/transpilation/jsenv_plugin_transpilation.js +1 -2
  135. package/src/plugins/url_analysis/css/css_urls.js +1 -1
  136. package/src/plugins/url_analysis/html/html_urls.js +4 -1
  137. package/src/plugins/url_analysis/js/js_urls.js +3 -2
  138. package/src/plugins/url_analysis/jsenv_plugin_url_analysis.js +94 -1
  139. package/src/plugins/url_analysis/webmanifest/webmanifest_urls.js +3 -0
  140. package/src/plugins/url_resolution/jsenv_plugin_url_resolution.js +0 -3
  141. package/src/test/execute_plan.js +3 -1
  142. package/dist/event_source_client.js.map +0 -188
  143. package/dist/html_supervisor_installer.js +0 -1236
  144. package/dist/html_supervisor_installer.js.map +0 -337
  145. package/dist/html_supervisor_setup.js +0 -95
  146. package/dist/html_supervisor_setup.js.map +0 -57
  147. package/dist/import_meta_hot.js.map +0 -42
  148. package/src/jsenv_root_directory_url.js +0 -1
  149. package/src/omega/compat/default_runtime_compat.js +0 -11
  150. package/src/plugins/filesystem_magic/jsenv_plugin_filesystem_magic.js +0 -61
  151. package/src/plugins/transpilation/babel/new_stylesheet/client/.eslintrc.cjs +0 -24
@@ -6,15 +6,17 @@ import { jsenvPluginNodeEsmResolution } from "./node_esm_resolution/jsenv_plugin
6
6
  import { jsenvPluginUrlVersion } from "./url_version/jsenv_plugin_url_version.js"
7
7
  import { jsenvPluginFileUrls } from "./file_urls/jsenv_plugin_file_urls.js"
8
8
  import { jsenvPluginHttpUrls } from "./http_urls/jsenv_plugin_http_urls.js"
9
- import { jsenvPluginFileSystemMagic } from "./filesystem_magic/jsenv_plugin_filesystem_magic.js"
10
9
  import { jsenvPluginInline } from "./inline/jsenv_plugin_inline.js"
11
10
  import { jsenvPluginHtmlSupervisor } from "./html_supervisor/jsenv_plugin_html_supervisor.js"
12
11
  import { jsenvPluginCommonJsGlobals } from "./commonjs_globals/jsenv_plugin_commonjs_globals.js"
13
12
  import { jsenvPluginImportMetaScenarios } from "./import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js"
14
13
  import { jsenvPluginInjectGlobals } from "./inject_globals/jsenv_plugin_inject_globals.js"
15
14
  import { jsenvPluginTranspilation } from "./transpilation/jsenv_plugin_transpilation.js"
15
+ import { jsenvPluginNodeRuntime } from "./node_runtime/jsenv_plugin_node_runtime.js"
16
+ // build only
16
17
  import { jsenvPluginBundling } from "./bundling/jsenv_plugin_bundling.js"
17
18
  import { jsenvPluginMinification } from "./minification/jsenv_plugin_minification.js"
19
+ // autoreload
18
20
  import { jsenvPluginImportMetaHot } from "./import_meta_hot/jsenv_plugin_import_meta_hot.js"
19
21
  import { jsenvPluginAutoreload } from "./autoreload/jsenv_plugin_autoreload.js"
20
22
  import { jsenvPluginCacheControl } from "./cache_control/jsenv_plugin_cache_control.js"
@@ -23,10 +25,13 @@ export const getCorePlugins = ({
23
25
  rootDirectoryUrl,
24
26
  urlGraph,
25
27
  scenario,
28
+ runtimeCompat,
26
29
 
30
+ urlAnalysis = {},
27
31
  htmlSupervisor,
28
32
  nodeEsmResolution,
29
33
  fileSystemMagicResolution,
34
+ directoryReferenceAllowed,
30
35
  injectedGlobals,
31
36
  transpilation = true,
32
37
  minification = false,
@@ -43,42 +48,34 @@ export const getCorePlugins = ({
43
48
  nodeEsmResolution = {}
44
49
  }
45
50
  return [
46
- jsenvPluginUrlAnalysis(),
47
- jsenvPluginTranspilation({
48
- rootDirectoryUrl,
49
- ...transpilation,
50
- }),
51
- ...(htmlSupervisor
52
- ? [
53
- jsenvPluginHtmlSupervisor({
54
- rootDirectoryUrl,
55
- ...htmlSupervisor,
56
- }),
57
- ]
58
- : []), // before inline as it turns inline <script> into <script src>
51
+ jsenvPluginUrlAnalysis({ rootDirectoryUrl, ...urlAnalysis }),
52
+ jsenvPluginTranspilation(transpilation),
53
+ ...(htmlSupervisor ? [jsenvPluginHtmlSupervisor(htmlSupervisor)] : []), // before inline as it turns inline <script> into <script src>
59
54
  jsenvPluginInline(), // before "file urls" to resolve and load inline urls
60
55
  jsenvPluginImportmap(), // before node esm to handle bare specifiers before node esm
61
- jsenvPluginFileUrls(),
56
+ jsenvPluginFileUrls({
57
+ directoryReferenceAllowed,
58
+ ...fileSystemMagicResolution,
59
+ }),
62
60
  jsenvPluginHttpUrls(),
63
61
  jsenvPluginLeadingSlash(),
64
62
  // before url resolution to handle "js_import_export" resolution
65
63
  jsenvPluginNodeEsmResolution({
66
64
  rootDirectoryUrl,
65
+ runtimeCompat,
67
66
  ...nodeEsmResolution,
68
67
  }),
69
68
  jsenvPluginUrlResolution(),
70
- jsenvPluginFileSystemMagic(fileSystemMagicResolution),
71
69
  jsenvPluginUrlVersion(),
72
70
  jsenvPluginInjectGlobals(injectedGlobals),
73
71
  jsenvPluginCommonJsGlobals(),
74
72
  jsenvPluginImportMetaScenarios(),
75
73
 
74
+ jsenvPluginNodeRuntime({ runtimeCompat }),
76
75
  jsenvPluginBundling(bundling),
77
76
  jsenvPluginMinification(minification),
78
77
 
79
- jsenvPluginImportMetaHot({
80
- rootDirectoryUrl,
81
- }),
78
+ jsenvPluginImportMetaHot(),
82
79
  ...(clientAutoreload
83
80
  ? [
84
81
  jsenvPluginAutoreload({
@@ -12,32 +12,25 @@
12
12
  */
13
13
 
14
14
  import { createRequire } from "node:module"
15
- import { readFileSync, urlToFilename, urlIsInsideOf } from "@jsenv/filesystem"
15
+ import { readFileSync, urlToFilename } from "@jsenv/filesystem"
16
16
 
17
17
  import { requireBabelPlugin } from "@jsenv/babel-plugins"
18
18
  import { applyBabelPlugins } from "@jsenv/utils/js_ast/apply_babel_plugins.js"
19
19
  import { injectQueryParams } from "@jsenv/utils/urls/url_utils.js"
20
20
  import { createMagicSource } from "@jsenv/utils/sourcemap/magic_source.js"
21
21
  import { composeTwoSourcemaps } from "@jsenv/utils/sourcemap/sourcemap_composition_v3.js"
22
- import { fetchOriginalUrlInfo } from "@jsenv/utils/graph/fetch_original_url_info.js"
23
22
 
24
- import { jsenvRootDirectoryUrl } from "@jsenv/core/src/jsenv_root_directory_url.js"
25
23
  import { babelPluginTransformImportMetaUrl } from "./helpers/babel_plugin_transform_import_meta_url.js"
26
- import { jsenvPluginAsJsClassicHtml } from "./jsenv_plugin_script_type_module_as_classic.js"
24
+ import { jsenvPluginAsJsClassicHtml } from "./jsenv_plugin_as_js_classic_html.js"
27
25
  import { jsenvPluginAsJsClassicWorkers } from "./jsenv_plugin_as_js_classic_workers.js"
28
26
 
29
27
  const require = createRequire(import.meta.url)
30
28
 
31
- export const jsenvPluginAsJsClassic = ({
32
- rootDirectoryUrl,
33
- systemJsInjection,
34
- }) => {
35
- const preferSourceFiles =
36
- rootDirectoryUrl === jsenvRootDirectoryUrl ||
37
- urlIsInsideOf(rootDirectoryUrl, jsenvRootDirectoryUrl)
38
- const systemJsClientFileUrl = preferSourceFiles
39
- ? new URL("./client/s.js", import.meta.url).href
40
- : new URL("./dist/s.js", import.meta.url).href
29
+ export const jsenvPluginAsJsClassic = ({ systemJsInjection }) => {
30
+ const systemJsClientFileUrl = new URL(
31
+ "./client/s.js?js_classic",
32
+ import.meta.url,
33
+ ).href
41
34
 
42
35
  return [
43
36
  jsenvPluginAsJsClassicConversion({
@@ -98,7 +91,7 @@ const jsenvPluginAsJsClassicConversion = ({
98
91
  },
99
92
  },
100
93
  fetchUrlContent: async (urlInfo, context) => {
101
- const originalUrlInfo = await fetchOriginalUrlInfo({
94
+ const originalUrlInfo = await context.fetchOriginalUrlInfo({
102
95
  urlInfo,
103
96
  context,
104
97
  searchParam: "as_js_classic",
@@ -132,6 +125,8 @@ const jsenvPluginAsJsClassicConversion = ({
132
125
  })
133
126
  urlInfo.data.jsClassicFormat = jsClassicFormat
134
127
  return {
128
+ originalUrl: originalUrlInfo.originalUrl,
129
+ originalContent: originalUrlInfo.originalContent,
135
130
  type: "js_classic",
136
131
  contentType: "text/javascript",
137
132
  content,
@@ -198,18 +193,21 @@ const convertJsModuleToJsClassic = async ({
198
193
  ],
199
194
  urlInfo,
200
195
  })
196
+ let sourcemap = urlInfo.sourcemap
197
+ sourcemap = await composeTwoSourcemaps(sourcemap, map)
201
198
  if (systemJsInjection && jsClassicFormat === "system" && isJsEntryPoint) {
202
199
  const magicSource = createMagicSource(code)
203
200
  const systemjsCode = readFileSync(systemJsClientFileUrl, { as: "string" })
204
201
  magicSource.prepend(`${systemjsCode}\n\n`)
205
- const { content, sourcemap } = magicSource.toContentAndSourcemap()
202
+ const magicResult = magicSource.toContentAndSourcemap()
203
+ sourcemap = await composeTwoSourcemaps(sourcemap, magicResult.sourcemap)
206
204
  return {
207
- content,
208
- sourcemap: await composeTwoSourcemaps(map, sourcemap),
205
+ content: magicResult.content,
206
+ sourcemap,
209
207
  }
210
208
  }
211
209
  return {
212
210
  content: code,
213
- sourcemap: map,
211
+ sourcemap,
214
212
  }
215
213
  }
@@ -14,7 +14,6 @@ import { urlToFilename } from "@jsenv/filesystem"
14
14
 
15
15
  import { injectQueryParams } from "@jsenv/utils/urls/url_utils.js"
16
16
  import { JS_QUOTES } from "@jsenv/utils/string/js_quotes.js"
17
- import { fetchOriginalUrlInfo } from "@jsenv/utils/graph/fetch_original_url_info.js"
18
17
 
19
18
  export const jsenvPluginImportAssertions = () => {
20
19
  const updateReference = (reference, searchParam) => {
@@ -89,7 +88,7 @@ const jsenvPluginAsModules = () => {
89
88
  name: `jsenv:as_json_module`,
90
89
  appliesDuring: "*",
91
90
  fetchUrlContent: async (urlInfo, context) => {
92
- const originalUrlInfo = await fetchOriginalUrlInfo({
91
+ const originalUrlInfo = await context.fetchOriginalUrlInfo({
93
92
  urlInfo,
94
93
  context,
95
94
  searchParam: "as_json_module",
@@ -100,6 +99,8 @@ const jsenvPluginAsModules = () => {
100
99
  }
101
100
  const jsonText = JSON.stringify(originalUrlInfo.content.trim())
102
101
  return {
102
+ originalUrl: originalUrlInfo.originalUrl,
103
+ originalContent: originalUrlInfo.originalContent,
103
104
  type: "js_module",
104
105
  contentType: "text/javascript",
105
106
  // here we could `export default ${jsonText}`:
@@ -114,7 +115,7 @@ const jsenvPluginAsModules = () => {
114
115
  name: `jsenv:as_css_module`,
115
116
  appliesDuring: "*",
116
117
  fetchUrlContent: async (urlInfo, context) => {
117
- const originalUrlInfo = await fetchOriginalUrlInfo({
118
+ const originalUrlInfo = await context.fetchOriginalUrlInfo({
118
119
  urlInfo,
119
120
  context,
120
121
  searchParam: "as_css_module",
@@ -130,6 +131,8 @@ const jsenvPluginAsModules = () => {
130
131
  canUseTemplateString: true,
131
132
  })
132
133
  return {
134
+ originalUrl: originalUrlInfo.originalUrl,
135
+ originalContent: originalUrlInfo.originalContent,
133
136
  type: "js_module",
134
137
  contentType: "text/javascript",
135
138
  content: `import { InlineContent } from ${JSON.stringify(
@@ -148,7 +151,7 @@ const jsenvPluginAsModules = () => {
148
151
  name: `jsenv:as_text_module`,
149
152
  appliesDuring: "*",
150
153
  fetchUrlContent: async (urlInfo, context) => {
151
- const originalUrlInfo = await fetchOriginalUrlInfo({
154
+ const originalUrlInfo = await context.fetchOriginalUrlInfo({
152
155
  urlInfo,
153
156
  context,
154
157
  searchParam: "as_text_module",
@@ -164,6 +167,8 @@ const jsenvPluginAsModules = () => {
164
167
  canUseTemplateString: true,
165
168
  })
166
169
  return {
170
+ originalUrl: originalUrlInfo.originalUrl,
171
+ originalContent: originalUrlInfo.originalContent,
167
172
  type: "js_module",
168
173
  contentType: "text/javascript",
169
174
  content: `import { InlineContent } from ${JSON.stringify(
@@ -14,7 +14,6 @@ import { jsenvPluginBabel } from "./babel/jsenv_plugin_babel.js"
14
14
  import { jsenvPluginTopLevelAwait } from "./jsenv_plugin_top_level_await.js"
15
15
 
16
16
  export const jsenvPluginTranspilation = ({
17
- rootDirectoryUrl,
18
17
  importAssertions = true,
19
18
  css = true,
20
19
  jsModuleAsJsClassic = true,
@@ -37,7 +36,7 @@ export const jsenvPluginTranspilation = ({
37
36
  // so the build function will disable jsModuleAsJsClassic during build
38
37
  // and enable it manually during postbuild
39
38
  ...(jsModuleAsJsClassic
40
- ? [jsenvPluginAsJsClassic({ rootDirectoryUrl, systemJsInjection })]
39
+ ? [jsenvPluginAsJsClassic({ systemJsInjection })]
41
40
  : []),
42
41
  // topLevelAwait must come after js_module_as_js_classic because it's related to the module format
43
42
  // so we want to wait to know the module format before transforming things related to top level await
@@ -41,7 +41,7 @@ export const parseAndTransformCssUrls = async (urlInfo, context) => {
41
41
  },
42
42
  }),
43
43
  ],
44
- url: urlInfo.data.rawUrl || urlInfo.url,
44
+ url: urlInfo.originalUrl,
45
45
  content: urlInfo.content,
46
46
  })
47
47
  await Promise.all(actions.map((action) => action()))
@@ -8,7 +8,7 @@ import {
8
8
  import { htmlAttributeSrcSet } from "@jsenv/utils/html_ast/html_attribute_src_set.js"
9
9
 
10
10
  export const parseAndTransformHtmlUrls = async (urlInfo, context) => {
11
- const url = urlInfo.data.rawUrl || urlInfo.url
11
+ const url = urlInfo.originalUrl
12
12
  const content = urlInfo.content
13
13
  const { scenario, referenceUtils } = context
14
14
  const htmlAst = parseHtmlString(content, {
@@ -51,6 +51,9 @@ export const parseAndTransformHtmlUrls = async (urlInfo, context) => {
51
51
  })
52
52
  },
53
53
  })
54
+ if (actions.length === 0) {
55
+ return null
56
+ }
54
57
  await Promise.all(actions.map((action) => action()))
55
58
  return {
56
59
  content: stringifyHtmlAst(htmlAst),
@@ -5,7 +5,7 @@ import { isWebWorkerUrlInfo } from "@jsenv/core/src/omega/web_workers.js"
5
5
  export const parseAndTransformJsUrls = async (urlInfo, context) => {
6
6
  const jsMentions = await parseJsUrls({
7
7
  js: urlInfo.content,
8
- url: (urlInfo.data && urlInfo.data.rawUrl) || urlInfo.url,
8
+ url: urlInfo.originalUrl,
9
9
  isJsModule: urlInfo.type === "js_module",
10
10
  isWebWorker: isWebWorkerUrlInfo(urlInfo),
11
11
  })
@@ -51,10 +51,11 @@ export const parseAndTransformJsUrls = async (urlInfo, context) => {
51
51
  typePropertyNode: jsMention.typePropertyNode,
52
52
  })
53
53
  actions.push(async () => {
54
+ const replacement = await referenceUtils.readGeneratedSpecifier(reference)
54
55
  magicSource.replace({
55
56
  start: jsMention.specifierStart,
56
57
  end: jsMention.specifierEnd,
57
- replacement: await referenceUtils.readGeneratedSpecifier(reference),
58
+ replacement,
58
59
  })
59
60
  if (reference.mutation) {
60
61
  reference.mutation(magicSource)
@@ -1,18 +1,111 @@
1
+ import {
2
+ normalizeStructuredMetaMap,
3
+ urlToMeta,
4
+ urlToRelativeUrl,
5
+ } from "@jsenv/filesystem"
6
+
1
7
  import { parseAndTransformHtmlUrls } from "./html/html_urls.js"
2
8
  import { parseAndTransformCssUrls } from "./css/css_urls.js"
3
9
  import { parseAndTransformJsUrls } from "./js/js_urls.js"
4
10
  import { parseAndTransformWebmanifestUrls } from "./webmanifest/webmanifest_urls.js"
5
11
 
6
- export const jsenvPluginUrlAnalysis = () => {
12
+ export const jsenvPluginUrlAnalysis = ({ rootDirectoryUrl, include }) => {
13
+ let getIncludeInfo = () => undefined
14
+ if (include) {
15
+ const includeMetaMap = normalizeStructuredMetaMap(
16
+ {
17
+ include,
18
+ },
19
+ rootDirectoryUrl,
20
+ )
21
+ getIncludeInfo = (url) => {
22
+ const meta = urlToMeta({
23
+ url,
24
+ structuredMetaMap: includeMetaMap,
25
+ })
26
+ return meta.include
27
+ }
28
+ }
29
+
7
30
  return {
8
31
  name: "jsenv:url_analysis",
9
32
  appliesDuring: "*",
33
+ redirectUrl: (reference) => {
34
+ if (
35
+ reference.specifier[0] === "#" &&
36
+ // For Html, css and in general "#" refer to a ressource in the page
37
+ // so that urls must be kept intact
38
+ // However for js import specifiers they have a different meaning and we want
39
+ // to resolve them (https://nodejs.org/api/packages.html#imports for instance)
40
+ reference.type !== "js_import_export"
41
+ ) {
42
+ reference.shouldHandle = false
43
+ return
44
+ }
45
+ const includeInfo = getIncludeInfo(reference.url)
46
+ if (includeInfo === true) {
47
+ reference.shouldHandle = true
48
+ return
49
+ }
50
+ if (includeInfo === false) {
51
+ reference.shouldHandle = false
52
+ return
53
+ }
54
+ if (reference.url.startsWith("data:")) {
55
+ reference.shouldHandle = true
56
+ return
57
+ }
58
+ if (reference.url.startsWith("file:")) {
59
+ reference.shouldHandle = true
60
+ return
61
+ }
62
+ },
10
63
  transformUrlContent: {
11
64
  html: parseAndTransformHtmlUrls,
12
65
  css: parseAndTransformCssUrls,
13
66
  js_classic: parseAndTransformJsUrls,
14
67
  js_module: parseAndTransformJsUrls,
15
68
  webmanifest: parseAndTransformWebmanifestUrls,
69
+ directory: (urlInfo, context) => {
70
+ const originalDirectoryReference = findOriginalDirectoryReference(
71
+ urlInfo,
72
+ context,
73
+ )
74
+ const directoryRelativeUrl = urlToRelativeUrl(
75
+ urlInfo.url,
76
+ context.rootDirectoryUrl,
77
+ )
78
+ JSON.parse(urlInfo.content).forEach((directoryEntryName) => {
79
+ context.referenceUtils.found({
80
+ type: "filesystem",
81
+ subtype: "directory_entry",
82
+ specifier: directoryEntryName,
83
+ trace: `"${directoryRelativeUrl}${directoryEntryName}" entry in directory referenced by ${originalDirectoryReference.trace}`,
84
+ })
85
+ })
86
+ },
16
87
  },
17
88
  }
18
89
  }
90
+
91
+ const findOriginalDirectoryReference = (urlInfo, context) => {
92
+ const findNonFileSystemAncestor = (urlInfo) => {
93
+ for (const dependentUrl of urlInfo.dependents) {
94
+ const dependentUrlInfo = context.urlGraph.getUrlInfo(dependentUrl)
95
+ if (dependentUrlInfo.type !== "directory") {
96
+ return [dependentUrlInfo, urlInfo]
97
+ }
98
+ const found = findNonFileSystemAncestor(dependentUrlInfo)
99
+ if (found) {
100
+ return found
101
+ }
102
+ }
103
+ return []
104
+ }
105
+ const [ancestor, child] = findNonFileSystemAncestor(urlInfo)
106
+ if (!ancestor) {
107
+ return null
108
+ }
109
+ const ref = ancestor.references.find((ref) => ref.url === child.url)
110
+ return ref
111
+ }
@@ -12,6 +12,9 @@ export const parseAndTransformWebmanifestUrls = async (urlInfo, context) => {
12
12
  icon.src = await context.referenceUtils.readGeneratedSpecifier(reference)
13
13
  })
14
14
  })
15
+ if (actions.length === 0) {
16
+ return null
17
+ }
15
18
  await Promise.all(actions.map((action) => action()))
16
19
  return JSON.stringify(manifest, null, " ")
17
20
  }
@@ -1,8 +1,5 @@
1
1
  export const jsenvPluginUrlResolution = () => {
2
2
  const urlResolver = (reference) => {
3
- if (reference.specifier[0] === "#") {
4
- reference.external = true
5
- }
6
3
  return new URL(
7
4
  reference.specifier,
8
5
  reference.baseUrl || reference.parentUrl,
@@ -132,6 +132,7 @@ export const executePlan = async (
132
132
  urlGraph,
133
133
  scenario,
134
134
  sourcemaps,
135
+ runtimeCompat: runtimes,
135
136
  writeGeneratedFiles,
136
137
  plugins: [
137
138
  ...plugins,
@@ -139,6 +140,7 @@ export const executePlan = async (
139
140
  rootDirectoryUrl,
140
141
  urlGraph,
141
142
  scenario,
143
+ runtimeCompat: runtimes,
142
144
 
143
145
  htmlSupervisor: true,
144
146
  nodeEsmResolution,
@@ -212,7 +214,7 @@ export const executePlan = async (
212
214
  // if there is an error during execution npm will mess up the output
213
215
  // (happens when npm runs several command in a workspace)
214
216
  // so we enable spinner only when !process.exitCode (no error so far)
215
- !process.exitCode
217
+ process.exitCode !== 1
216
218
 
217
219
  const startMs = Date.now()
218
220
  const report = {}