@jsenv/core 27.0.0-alpha.8 → 27.0.0-alpha.9

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/build/build.js +29 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "27.0.0-alpha.8",
3
+ "version": "27.0.0-alpha.9",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -185,28 +185,38 @@ ${Object.keys(rawGraph.urlInfos).join("\n")}`,
185
185
  }
186
186
  Object.keys(rawGraph.urlInfos).forEach((rawUrl) => {
187
187
  const rawUrlInfo = rawGraph.getUrlInfo(rawUrl)
188
- if (!rawUrlInfo.data.isEntryPoint) {
189
- return
190
- }
191
- addToBundlerIfAny(rawUrlInfo)
192
- if (rawUrlInfo.type === "html") {
193
- rawUrlInfo.dependencies.forEach((dependencyUrl) => {
194
- const dependencyUrlInfo = rawGraph.getUrlInfo(dependencyUrl)
195
- if (dependencyUrlInfo.isInline) {
196
- if (dependencyUrlInfo.type === "js_module") {
197
- // bundle inline script type module deps
198
- dependencyUrlInfo.references.forEach((inlineScriptRef) => {
199
- if (inlineScriptRef.type === "js_import_export") {
200
- addToBundlerIfAny(rawGraph.getUrlInfo(inlineScriptRef.url))
201
- }
202
- })
188
+ if (rawUrlInfo.data.isEntryPoint) {
189
+ addToBundlerIfAny(rawUrlInfo)
190
+ if (rawUrlInfo.type === "html") {
191
+ rawUrlInfo.dependencies.forEach((dependencyUrl) => {
192
+ const dependencyUrlInfo = rawGraph.getUrlInfo(dependencyUrl)
193
+ if (dependencyUrlInfo.isInline) {
194
+ if (dependencyUrlInfo.type === "js_module") {
195
+ // bundle inline script type module deps
196
+ dependencyUrlInfo.references.forEach((inlineScriptRef) => {
197
+ if (inlineScriptRef.type === "js_import_export") {
198
+ addToBundlerIfAny(rawGraph.getUrlInfo(inlineScriptRef.url))
199
+ }
200
+ })
201
+ }
202
+ // inline content cannot be bundled
203
+ return
203
204
  }
204
- // inline content cannot be bundled
205
- return
205
+ addToBundlerIfAny(dependencyUrlInfo)
206
+ })
207
+ return
208
+ }
209
+ }
210
+ // File referenced with new URL('./file.js', import.meta.url)
211
+ // are entry points that can be bundled
212
+ // For instance we will bundle service worker/workers detected like this
213
+ if (rawUrlInfo.type === "js_module") {
214
+ rawUrlInfo.references.forEach((reference) => {
215
+ if (reference.type === "js_import_meta_url_pattern") {
216
+ const urlInfo = rawGraph.getUrlInfo(reference.url)
217
+ addToBundlerIfAny(urlInfo)
206
218
  }
207
- addToBundlerIfAny(dependencyUrlInfo)
208
219
  })
209
- return
210
220
  }
211
221
  })
212
222
  await Object.keys(bundlers).reduce(async (previous, type) => {