@jsenv/core 27.0.0-alpha.46 → 27.0.0-alpha.49

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.
@@ -5,27 +5,24 @@
5
5
  "../src/plugins/html_supervisor/client/html_supervisor_setup.js"
6
6
  ],
7
7
  "sourcesContent": [
8
- "window.__html_supervisor__ = {\n // \"html_supervisor_installer.js\" will implement\n // - \"addExecution\"\n // - \"collectScriptResults\"\n // - \"superviseScriptTypeModule\"\n // and take all executions in \"executions\" and implement their supervision\n executions: [],\n addExecution: (execution) => {\n window.__html_supervisor__.executions.push(execution)\n },\n collectScriptResults: () => {\n throw new Error(\"htmlSupervisor not installed\")\n },\n superviseScriptTypeModule: () => {\n throw new Error(\"htmlSupervisor not installed\")\n },\n superviseScript: ({ src, crossorigin, integrity }) => {\n window.__html_supervisor__.addExecution({\n type: \"js_classic\",\n improveErrorWithFetch: true,\n currentScript: document.currentScript,\n src,\n promise: new Promise((resolve, reject) => {\n const script = document.createElement(\"script\")\n if (crossorigin) {\n script.crossorigin = crossorigin\n }\n if (integrity) {\n script.integrity = integrity\n }\n script.src = src\n const scriptUrl = new URL(src, window.location).href\n let lastWindowErrorUrl\n let lastWindowError\n const windowErrorCallback = (e) => {\n lastWindowErrorUrl = e.filename\n lastWindowError = e.error\n }\n const cleanup = () => {\n document.body.removeChild(script)\n window.removeEventListener(\"error\", windowErrorCallback)\n }\n window.addEventListener(\"error\", windowErrorCallback)\n script.addEventListener(\"error\", () => {\n cleanup()\n reject(src)\n })\n script.addEventListener(\"load\", () => {\n cleanup()\n if (lastWindowErrorUrl === scriptUrl) {\n reject(lastWindowError)\n } else {\n resolve()\n }\n })\n document.body.appendChild(script)\n }),\n })\n },\n getScriptExecutionResults: () => {\n // wait for page to load before collecting script execution results\n const htmlReadyPromise = new Promise((resolve) => {\n if (document.readyState === \"complete\") {\n resolve()\n return\n }\n const loadCallback = () => {\n window.removeEventListener(\"load\", loadCallback)\n resolve()\n }\n window.addEventListener(\"load\", loadCallback)\n })\n return htmlReadyPromise.then(() => {\n return window.__html_supervisor__.collectScriptResults()\n })\n },\n}\n"
8
+ "window.__html_supervisor__ = {\n // \"html_supervisor_installer.js\" will implement\n // - \"addScriptToExecute\"\n // - \"superviseScriptTypeModule\"\n // - \"collectScriptResults\"\n // and take all executions in \"scriptsToExecute\" and implement their supervision\n scriptsToExecute: [],\n addScriptToExecute: (scriptToExecute) => {\n window.__html_supervisor__.scriptsToExecute.push(scriptToExecute)\n },\n superviseScript: ({ src, isInline, crossorigin, integrity }) => {\n window.__html_supervisor__.addScriptToExecute({\n src,\n type: \"js_classic\",\n isInline,\n currentScript: document.currentScript,\n execute: () => {\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\")\n if (crossorigin) {\n script.crossorigin = crossorigin\n }\n if (integrity) {\n script.integrity = integrity\n }\n script.src = src\n const scriptUrl = new URL(src, window.location).href\n let lastWindowErrorUrl\n let lastWindowError\n const windowErrorCallback = (e) => {\n lastWindowErrorUrl = e.filename\n lastWindowError = e.error\n }\n const cleanup = () => {\n document.body.removeChild(script)\n window.removeEventListener(\"error\", windowErrorCallback)\n }\n window.addEventListener(\"error\", windowErrorCallback)\n script.addEventListener(\"error\", () => {\n cleanup()\n reject(src)\n })\n script.addEventListener(\"load\", () => {\n cleanup()\n if (lastWindowErrorUrl === scriptUrl) {\n reject(lastWindowError)\n } else {\n resolve()\n }\n })\n document.body.appendChild(script)\n })\n },\n })\n },\n superviseScriptTypeModule: () => {\n throw new Error(\"htmlSupervisor not installed\")\n },\n getScriptExecutionResults: () => {\n // wait for page to load before collecting script execution results\n const htmlReadyPromise = new Promise((resolve) => {\n if (document.readyState === \"complete\") {\n resolve()\n return\n }\n const loadCallback = () => {\n window.removeEventListener(\"load\", loadCallback)\n resolve()\n }\n window.addEventListener(\"load\", loadCallback)\n })\n return htmlReadyPromise.then(() => {\n return window.__html_supervisor__.collectScriptResults()\n })\n },\n collectScriptResults: () => {\n throw new Error(\"htmlSupervisor not installed\")\n },\n}\n"
9
9
  ],
10
10
  "names": [
11
11
  "window",
12
12
  "__html_supervisor__",
13
- "executions",
14
- "addExecution",
15
- "execution",
13
+ "scriptsToExecute",
14
+ "addScriptToExecute",
15
+ "scriptToExecute",
16
16
  "push",
17
- "collectScriptResults",
18
- "Error",
19
- "superviseScriptTypeModule",
20
17
  "superviseScript",
21
18
  "src",
19
+ "isInline",
22
20
  "crossorigin",
23
21
  "integrity",
24
22
  "type",
25
- "improveErrorWithFetch",
26
23
  "currentScript",
27
24
  "document",
28
- "promise",
25
+ "execute",
29
26
  "Promise",
30
27
  "resolve",
31
28
  "reject",
@@ -47,11 +44,14 @@
47
44
  "removeEventListener",
48
45
  "addEventListener",
49
46
  "appendChild",
47
+ "superviseScriptTypeModule",
48
+ "Error",
50
49
  "getScriptExecutionResults",
51
50
  "htmlReadyPromise",
52
51
  "readyState",
53
52
  "loadCallback",
54
- "then"
53
+ "then",
54
+ "collectScriptResults"
55
55
  ],
56
- "mappings": "AAAAA,MAAM,CAACC,mBAAP,GAA6B;AAC3B;AACA;AACA;AACA;AACA;AACAC,EAAAA,UAAU,EAAE,EANe;EAO3BC,YAAY,EAAGC,SAAD,IAAe;AAC3BJ,IAAAA,MAAM,CAACC,mBAAP,CAA2BC,UAA3B,CAAsCG,IAAtC,CAA2CD,SAA3C,CAAA,CAAA;GARyB;AAU3BE,EAAAA,oBAAoB,EAAE,MAAM;AAC1B,IAAA,MAAM,IAAIC,KAAJ,CAAU,8BAAV,CAAN,CAAA;GAXyB;AAa3BC,EAAAA,yBAAyB,EAAE,MAAM;AAC/B,IAAA,MAAM,IAAID,KAAJ,CAAU,8BAAV,CAAN,CAAA;GAdyB;AAgB3BE,EAAAA,eAAe,EAAE,CAAC;IAAEC,GAAF;IAAOC,WAAP;AAAoBC,IAAAA,SAAAA;AAApB,GAAD,KAAqC;AACpDZ,IAAAA,MAAM,CAACC,mBAAP,CAA2BE,YAA3B,CAAwC;AACtCU,MAA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AACjC,MAAA,OAAO1C,MAAM,CAACC,mBAAP,CAA2B0C,oBAA3B,EAAP,CAAA;AACD,KAFM,CAAP,CAAA;GAvEyB;AA2E3BA,EAAAA,oBAAoB,EAAE,MAAM;AAC1B,IAAA,MAAM,IAAIN,KAAJ,CAAU,8BAAV,CAAN,CAAA;AACD,GAAA;AA7E0B,CAA7B"
57
57
  }
@@ -0,0 +1,86 @@
1
+ /*
2
+ * https://vitejs.dev/guide/api-hmr.html#hot-accept-deps-cb
3
+ * https://modern-web.dev/docs/dev-server/plugins/hmr/
4
+ */
5
+ const urlHotMetas = {};
6
+ const createImportMetaHot = importMetaUrl => {
7
+ const data = {};
8
+ const url = asUrlWithoutHmrQuery(importMetaUrl);
9
+ return {
10
+ data,
11
+ accept: (firstArg, secondArg) => {
12
+ if (!firstArg) {
13
+ addUrlMeta(url, {
14
+ dependencies: [url],
15
+ acceptCallback: () => {}
16
+ });
17
+ return;
18
+ }
19
+
20
+ if (typeof firstArg === "function") {
21
+ addUrlMeta(url, {
22
+ dependencies: [url],
23
+ acceptCallback: firstArg
24
+ });
25
+ return;
26
+ }
27
+
28
+ if (typeof firstArg === "string") {
29
+ addUrlMeta(url, {
30
+ dependencies: [firstArg],
31
+ acceptCallback: secondArg
32
+ });
33
+ return;
34
+ }
35
+
36
+ if (Array.isArray(firstArg)) {
37
+ addUrlMeta(url, {
38
+ dependencies: firstArg,
39
+ acceptCallback: secondArg
40
+ });
41
+ return;
42
+ }
43
+
44
+ throw new Error("invalid call to import.meta.hot.accept(), received ".concat(firstArg));
45
+ },
46
+ dispose: callback => {
47
+ addUrlMeta(url, {
48
+ disposeCallback: () => {
49
+ return callback(data);
50
+ }
51
+ });
52
+ },
53
+ decline: () => {
54
+ addUrlMeta(url, {
55
+ declined: true
56
+ });
57
+ },
58
+ invalidate: () => {
59
+ addUrlMeta(url, {
60
+ invalidated: true
61
+ });
62
+ }
63
+ };
64
+ };
65
+
66
+ const addUrlMeta = (url, meta) => {
67
+ urlHotMetas[url] = { ...urlHotMetas[url],
68
+ ...meta
69
+ };
70
+ };
71
+
72
+ const asUrlWithoutHmrQuery = url => {
73
+ const urlObject = new URL(url);
74
+
75
+ if (urlObject.searchParams.has("hmr")) {
76
+ urlObject.searchParams.delete("hmr");
77
+ urlObject.searchParams.delete("v");
78
+ return urlObject.href;
79
+ }
80
+
81
+ return url;
82
+ };
83
+
84
+ export { createImportMetaHot, urlHotMetas };
85
+
86
+ //# sourceMappingURL=import_meta_hot.js.map
@@ -0,0 +1,42 @@
1
+ {
2
+ "version": 3,
3
+ "file": "import_meta_hot.js",
4
+ "sources": [
5
+ "../src/plugins/import_meta_hot/client/import_meta_hot.js"
6
+ ],
7
+ "sourcesContent": [
8
+ "/*\n * https://vitejs.dev/guide/api-hmr.html#hot-accept-deps-cb\n * https://modern-web.dev/docs/dev-server/plugins/hmr/\n */\n\nexport const urlHotMetas = {}\n\nexport const createImportMetaHot = (importMetaUrl) => {\n const data = {}\n const url = asUrlWithoutHmrQuery(importMetaUrl)\n\n return {\n data,\n accept: (firstArg, secondArg) => {\n if (!firstArg) {\n addUrlMeta(url, {\n dependencies: [url],\n acceptCallback: () => {},\n })\n return\n }\n if (typeof firstArg === \"function\") {\n addUrlMeta(url, {\n dependencies: [url],\n acceptCallback: firstArg,\n })\n return\n }\n if (typeof firstArg === \"string\") {\n addUrlMeta(url, {\n dependencies: [firstArg],\n acceptCallback: secondArg,\n })\n return\n }\n if (Array.isArray(firstArg)) {\n addUrlMeta(url, {\n dependencies: firstArg,\n acceptCallback: secondArg,\n })\n return\n }\n throw new Error(\n `invalid call to import.meta.hot.accept(), received ${firstArg}`,\n )\n },\n dispose: (callback) => {\n addUrlMeta(url, {\n disposeCallback: () => {\n return callback(data)\n },\n })\n },\n decline: () => {\n addUrlMeta(url, {\n declined: true,\n })\n },\n invalidate: () => {\n addUrlMeta(url, {\n invalidated: true,\n })\n },\n }\n}\n\nconst addUrlMeta = (url, meta) => {\n urlHotMetas[url] = {\n ...urlHotMetas[url],\n ...meta,\n }\n}\n\nconst asUrlWithoutHmrQuery = (url) => {\n const urlObject = new URL(url)\n if (urlObject.searchParams.has(\"hmr\")) {\n urlObject.searchParams.delete(\"hmr\")\n urlObject.searchParams.delete(\"v\")\n return urlObject.href\n }\n return url\n}\n"
9
+ ],
10
+ "names": [
11
+ "urlHotMetas",
12
+ "createImportMetaHot",
13
+ "importMetaUrl",
14
+ "data",
15
+ "url",
16
+ "asUrlWithoutHmrQuery",
17
+ "accept",
18
+ "firstArg",
19
+ "secondArg",
20
+ "addUrlMeta",
21
+ "dependencies",
22
+ "acceptCallback",
23
+ "Array",
24
+ "isArray",
25
+ "Error",
26
+ "dispose",
27
+ "callback",
28
+ "disposeCallback",
29
+ "decline",
30
+ "declined",
31
+ "invalidate",
32
+ "invalidated",
33
+ "meta",
34
+ "urlObject",
35
+ "URL",
36
+ "searchParams",
37
+ "has",
38
+ "delete",
39
+ "href"
40
+ ],
41
+ "mappings": "AAAA;AACA;AACA;AACA;AAEO,MAAMA,WAAW,GAAG,GAApB;AAEMC,MAAAA,mBAAmB,GAAIC,aAAD,IAAmB;EACpD,MAAMC,IAAI,GAAG,EAAb,CAAA;AACA,EAAA,MAAMC,GAAG,GAAGC,oBAAoB,CAACH,aAAD,CAAhC,CAAA;EAEA,OAAO;IACLC,IADK;AAELG,IAAAA,MAAM,EAAE,CAACC,QAAD,EAAWC,SAAX,KAAyB;MAC/B,IAAI,CAACD,QAAL,EAAe;QACbE,UAAU,CAACL,GAAD,EAAM;UACdM,YAAY,EAAE,CAACN,GAAD,CADA;UAEdO,cAAc,EAAE,MAAM,EAAE;AAFV,SAAN,CAAV,CAAA;AAIA,QAAA,OAAA;AACD,OAAA;;AACD,MAAA,IAAI,OAAOJ,QAAP,KAAoB,UAAxB,EAAoC;QAClCE,UAAU,CAACL,GAAD,EAAM;UACdM,YAAY,EAAE,CAACN,GAAD,CADA;AAEdO,UAAAA,cAAc,EAAEJ,QAAAA;AAFF,SAAN,CAAV,CAA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B,GAAID,GAAD,IAAS;AACpC,EAAA,MAAMmB,SAAS,GAAG,IAAIC,GAAJ,CAAQpB,GAAR,CAAlB,CAAA;;EACA,IAAImB,SAAS,CAACE,YAAV,CAAuBC,GAAvB,CAA2B,KAA3B,CAAJ,EAAuC;AACrCH,IAAAA,SAAS,CAACE,YAAV,CAAuBE,MAAvB,CAA8B,KAA9B,CAAA,CAAA;AACAJ,IAAAA,SAAS,CAACE,YAAV,CAAuBE,MAAvB,CAA8B,GAA9B,CAAA,CAAA;IACA,OAAOJ,SAAS,CAACK,IAAjB,CAAA;AACD,GAAA;;AACD,EAAA,OAAOxB,GAAP,CAAA;AACD,CARD;;;;"
42
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "27.0.0-alpha.46",
3
+ "version": "27.0.0-alpha.49",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -60,7 +60,7 @@
60
60
  "@financial-times/polyfill-useragent-normaliser": "2.0.1",
61
61
  "@jsenv/abort": "4.1.2",
62
62
  "@jsenv/babel-plugins": "1.0.2",
63
- "@jsenv/filesystem": "3.2.1",
63
+ "@jsenv/filesystem": "3.2.2",
64
64
  "@jsenv/importmap": "1.2.0",
65
65
  "@jsenv/integrity": "0.0.1",
66
66
  "@jsenv/log": "1.5.2",
@@ -336,7 +336,7 @@ ${Object.keys(rawGraph.urlInfos).join("\n")}`,
336
336
  urlGraph: finalGraph,
337
337
  scenario: "build",
338
338
  sourcemaps,
339
- sourcemapsRelativeSources: true,
339
+ sourcemapsRelativeSources: !versioning,
340
340
  runtimeCompat,
341
341
  plugins: [
342
342
  jsenvPluginUrlAnalysis(),
@@ -510,12 +510,25 @@ ${Object.keys(rawGraph.urlInfos).join("\n")}`,
510
510
  }
511
511
  // remove eventual search params and hash
512
512
  const urlUntilPathname = asUrlUntilPathname(reference.generatedUrl)
513
- // if a file is in the same directory we could prefer the relative notation
514
- // but to keep things simple let's keep the "absolutely relative" to baseUrl for now
515
- const specifier = `${baseUrl}${urlToRelativeUrl(
516
- urlUntilPathname,
517
- buildDirectoryUrl,
518
- )}`
513
+ let specifier
514
+ if (baseUrl === "./") {
515
+ const relativeUrl = urlToRelativeUrl(
516
+ urlUntilPathname,
517
+ reference.parentUrl === rootDirectoryUrl
518
+ ? buildDirectoryUrl
519
+ : reference.parentUrl,
520
+ )
521
+ // ensure "./" on relative url (otherwise it could be a "bare specifier")
522
+ specifier =
523
+ relativeUrl[0] === "." ? relativeUrl : `./${relativeUrl}`
524
+ } else {
525
+ // if a file is in the same directory we could prefer the relative notation
526
+ // but to keep things simple let's keep the "absolutely relative" to baseUrl for now
527
+ specifier = `${baseUrl}${urlToRelativeUrl(
528
+ urlUntilPathname,
529
+ buildDirectoryUrl,
530
+ )}`
531
+ }
519
532
  buildUrls[specifier] = reference.generatedUrl
520
533
  return specifier
521
534
  },
@@ -860,6 +873,7 @@ const applyUrlVersioning = async ({
860
873
  urlGraph: finalGraph,
861
874
  scenario: "build",
862
875
  sourcemaps,
876
+ sourcemapsRelativeSources: true,
863
877
  runtimeCompat,
864
878
  plugins: [
865
879
  jsenvPluginUrlAnalysis(),
@@ -38,7 +38,7 @@ export const startDevServer = async ({
38
38
  clientFiles = {
39
39
  "./**": true,
40
40
  "./**/.*/": false, // any folder starting with a dot is ignored (includes .git,.jsenv for instance)
41
- "./dist/": false,
41
+ "./**/dist/": false,
42
42
  "./**/node_modules/": false,
43
43
  },
44
44
  cooldownBetweenFileEvents,
@@ -38,7 +38,7 @@ export const createKitchen = ({
38
38
  test: "inline",
39
39
  build: "none",
40
40
  }[scenario],
41
- sourcemapsSources = {
41
+ sourcemapsSourcesContent = {
42
42
  // during dev/test, chrome is able to find the sourcemap sources
43
43
  // as long as they use file:// protocol in the sourcemap files
44
44
  dev: false,
@@ -227,7 +227,7 @@ export const createKitchen = ({
227
227
  logger,
228
228
  urlGraph,
229
229
  sourcemaps,
230
- sourcemapsSources,
230
+ sourcemapsSourcesContent,
231
231
  sourcemapsRelativeSources,
232
232
  injectSourcemapPlaceholder: ({ urlInfo, specifier }) => {
233
233
  const sourcemapReference = createReference({
@@ -732,8 +732,8 @@ const applyReferenceEffectsOnUrlInfo = (reference, urlInfo, context) => {
732
732
  content: reference.isOriginalPosition
733
733
  ? parentUrlInfo.originalContent
734
734
  : parentUrlInfo.content,
735
- line: reference.line,
736
- column: reference.column,
735
+ line: reference.specifierLine,
736
+ column: reference.specifierColumn,
737
737
  }
738
738
  urlInfo.contentType = reference.contentType
739
739
  urlInfo.originalContent =
@@ -61,6 +61,10 @@ export const createFileService = ({
61
61
  reference.parentUrl,
62
62
  )
63
63
  try {
64
+ // urlInfo objects are reused, they must be "reset" before cooking then again
65
+ if (!urlInfo.isInline && !urlInfo.type === "sourcemap") {
66
+ urlGraph.resetUrlInfo(urlInfo)
67
+ }
64
68
  await kitchen.cook({
65
69
  reference: referenceFromGraph || reference,
66
70
  urlInfo,
@@ -10,7 +10,7 @@ import {
10
10
  export const createUrlInfoTransformer = ({
11
11
  logger,
12
12
  sourcemaps,
13
- sourcemapsSources,
13
+ sourcemapsSourcesContent,
14
14
  sourcemapsRelativeSources,
15
15
  urlGraph,
16
16
  injectSourcemapPlaceholder,
@@ -26,7 +26,7 @@ export const createUrlInfoTransformer = ({
26
26
  // for inline content (<script> insdide html)
27
27
  // chrome won't be able to fetch the file as it does not exists
28
28
  // so sourcemap must contain sources
29
- sourcemapsSources ||
29
+ sourcemapsSourcesContent ||
30
30
  urlInfo.isInline ||
31
31
  (sourcemap.sources &&
32
32
  sourcemap.sources.some(
@@ -160,7 +160,10 @@ export const createUrlInfoTransformer = ({
160
160
  urlInfo.content = SOURCEMAP.writeComment({
161
161
  contentType: urlInfo.contentType,
162
162
  content: urlInfo.content,
163
- specifier: sourcemapReference.generatedSpecifier,
163
+ specifier:
164
+ sourcemaps === "file" && sourcemapsRelativeSources
165
+ ? urlToRelativeUrl(sourcemapReference.url, urlInfo.url)
166
+ : sourcemapReference.generatedSpecifier,
164
167
  })
165
168
  }
166
169
  }
@@ -15,6 +15,16 @@ export const createUrlGraph = ({
15
15
  }
16
16
  }
17
17
  }
18
+ const resetUrlInfo = (urlInfo) => {
19
+ urlInfo.sourcemap = null
20
+ urlInfo.sourcemapReference = null
21
+ urlInfo.content = null
22
+ urlInfo.originalContent = null
23
+ urlInfo.type = null
24
+ urlInfo.subtype = null
25
+ urlInfo.data = {}
26
+ urlInfo.timing = {}
27
+ }
18
28
 
19
29
  const reuseOrCreateUrlInfo = (url) => {
20
30
  const existingUrlInfo = urlInfos[url]
@@ -150,6 +160,7 @@ export const createUrlGraph = ({
150
160
  reuseOrCreateUrlInfo,
151
161
  getUrlInfo,
152
162
  deleteUrlInfo,
163
+ resetUrlInfo,
153
164
  inferReference,
154
165
  findDependent,
155
166
  updateReferences,
@@ -1,11 +1,19 @@
1
- import { isFileSystemPath } from "@jsenv/filesystem"
1
+ import {
2
+ isFileSystemPath,
3
+ normalizeStructuredMetaMap,
4
+ urlToMeta,
5
+ } from "@jsenv/filesystem"
2
6
  import { createDetailedMessage } from "@jsenv/logger"
3
7
 
4
8
  import { applyRollupPlugins } from "@jsenv/utils/js_ast/apply_rollup_plugins.js"
5
9
  import { sourcemapConverter } from "@jsenv/utils/sourcemap/sourcemap_converter.js"
6
10
  import { fileUrlConverter } from "@jsenv/core/src/omega/file_url_converter.js"
7
11
 
8
- export const bundleJsModule = async ({ jsModuleUrlInfos, context }) => {
12
+ export const bundleJsModule = async ({
13
+ jsModuleUrlInfos,
14
+ context,
15
+ options,
16
+ }) => {
9
17
  const {
10
18
  signal,
11
19
  logger,
@@ -25,6 +33,7 @@ export const bundleJsModule = async ({ jsModuleUrlInfos, context }) => {
25
33
 
26
34
  runtimeCompat,
27
35
  sourcemaps,
36
+ options,
28
37
  })
29
38
  return jsModuleBundleUrlInfos
30
39
  }
@@ -39,6 +48,7 @@ export const buildWithRollup = async ({
39
48
 
40
49
  runtimeCompat,
41
50
  sourcemaps,
51
+ options,
42
52
  }) => {
43
53
  const resultRef = { current: null }
44
54
  try {
@@ -54,6 +64,7 @@ export const buildWithRollup = async ({
54
64
 
55
65
  runtimeCompat,
56
66
  sourcemaps,
67
+ options,
57
68
  resultRef,
58
69
  }),
59
70
  ],
@@ -86,6 +97,7 @@ const rollupPluginJsenv = ({
86
97
  urlGraph,
87
98
  jsModuleUrlInfos,
88
99
  sourcemaps,
100
+ options,
89
101
 
90
102
  resultRef,
91
103
  }) => {
@@ -98,6 +110,21 @@ const rollupPluginJsenv = ({
98
110
  ...chunk,
99
111
  })
100
112
  }
113
+ let importCanBeBundled = () => true
114
+ if (options.include) {
115
+ const bundleIncludeConfig = normalizeStructuredMetaMap(
116
+ {
117
+ bundle: options.include,
118
+ },
119
+ rootDirectoryUrl,
120
+ )
121
+ importCanBeBundled = (url) => {
122
+ return urlToMeta({
123
+ url,
124
+ structuredMetaMap: bundleIncludeConfig,
125
+ }).bundle
126
+ }
127
+ }
101
128
  const urlImporters = {}
102
129
 
103
130
  return {
@@ -207,6 +234,9 @@ const rollupPluginJsenv = ({
207
234
  if (!url.startsWith("file:")) {
208
235
  return { id: url, external: true }
209
236
  }
237
+ if (!importCanBeBundled(url)) {
238
+ return { id: url, external: true }
239
+ }
210
240
  const filePath = fileUrlConverter.asFilePath(url)
211
241
  return filePath
212
242
  },
@@ -23,28 +23,31 @@ export const jsenvPluginBundling = (bundling) => {
23
23
  },
24
24
  bundle: {
25
25
  css: bundling.css
26
- ? (cssUrlInfos, context) =>
27
- bundleCss({
26
+ ? (cssUrlInfos, context) => {
27
+ return bundleCss({
28
28
  cssUrlInfos,
29
29
  context,
30
30
  options: bundling.css,
31
31
  })
32
+ }
32
33
  : undefined,
33
34
  js_classic: bundling.js_classic
34
- ? (jsClassicUrlInfos, context) =>
35
- bundleJsClassicWorkers({
35
+ ? (jsClassicUrlInfos, context) => {
36
+ return bundleJsClassicWorkers({
36
37
  jsClassicUrlInfos,
37
38
  context,
38
39
  options: bundling.js_classic_workers,
39
40
  })
41
+ }
40
42
  : undefined,
41
43
  js_module: bundling.js_module
42
- ? (jsModuleUrlInfos, context) =>
43
- bundleJsModule({
44
+ ? (jsModuleUrlInfos, context) => {
45
+ return bundleJsModule({
44
46
  jsModuleUrlInfos,
45
47
  context,
46
48
  options: bundling.js_module,
47
49
  })
50
+ }
48
51
  : undefined,
49
52
  },
50
53
  }