@jsenv/core 40.9.1 → 40.11.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.
@@ -147,6 +147,14 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
147
147
  return 3;
148
148
  }
149
149
 
150
+ if (env.TERM === 'xterm-ghostty') {
151
+ return 3;
152
+ }
153
+
154
+ if (env.TERM === 'wezterm') {
155
+ return 3;
156
+ }
157
+
150
158
  if ('TERM_PROGRAM' in env) {
151
159
  const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
152
160
 
@@ -511,11 +519,10 @@ function isWide(x) {
511
519
  || x >= 0xFE54 && x <= 0xFE66
512
520
  || x >= 0xFE68 && x <= 0xFE6B
513
521
  || x >= 0x16FE0 && x <= 0x16FE4
514
- || x === 0x16FF0
515
- || x === 0x16FF1
516
- || x >= 0x17000 && x <= 0x187F7
517
- || x >= 0x18800 && x <= 0x18CD5
518
- || x >= 0x18CFF && x <= 0x18D08
522
+ || x >= 0x16FF0 && x <= 0x16FF6
523
+ || x >= 0x17000 && x <= 0x18CD5
524
+ || x >= 0x18CFF && x <= 0x18D1E
525
+ || x >= 0x18D80 && x <= 0x18DF2
519
526
  || x >= 0x1AFF0 && x <= 0x1AFF3
520
527
  || x >= 0x1AFF5 && x <= 0x1AFFB
521
528
  || x === 0x1AFFD
@@ -560,7 +567,7 @@ function isWide(x) {
560
567
  || x >= 0x1F680 && x <= 0x1F6C5
561
568
  || x === 0x1F6CC
562
569
  || x >= 0x1F6D0 && x <= 0x1F6D2
563
- || x >= 0x1F6D5 && x <= 0x1F6D7
570
+ || x >= 0x1F6D5 && x <= 0x1F6D8
564
571
  || x >= 0x1F6DC && x <= 0x1F6DF
565
572
  || x === 0x1F6EB
566
573
  || x === 0x1F6EC
@@ -571,11 +578,12 @@ function isWide(x) {
571
578
  || x >= 0x1F93C && x <= 0x1F945
572
579
  || x >= 0x1F947 && x <= 0x1F9FF
573
580
  || x >= 0x1FA70 && x <= 0x1FA7C
574
- || x >= 0x1FA80 && x <= 0x1FA89
575
- || x >= 0x1FA8F && x <= 0x1FAC6
576
- || x >= 0x1FACE && x <= 0x1FADC
577
- || x >= 0x1FADF && x <= 0x1FAE9
578
- || x >= 0x1FAF0 && x <= 0x1FAF8
581
+ || x >= 0x1FA80 && x <= 0x1FA8A
582
+ || x >= 0x1FA8E && x <= 0x1FAC6
583
+ || x === 0x1FAC8
584
+ || x >= 0x1FACD && x <= 0x1FADC
585
+ || x >= 0x1FADF && x <= 0x1FAEA
586
+ || x >= 0x1FAEF && x <= 0x1FAF8
579
587
  || x >= 0x20000 && x <= 0x2FFFD
580
588
  || x >= 0x30000 && x <= 0x3FFFD;
581
589
  }
@@ -147,6 +147,14 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
147
147
  return 3;
148
148
  }
149
149
 
150
+ if (env.TERM === 'xterm-ghostty') {
151
+ return 3;
152
+ }
153
+
154
+ if (env.TERM === 'wezterm') {
155
+ return 3;
156
+ }
157
+
150
158
  if ('TERM_PROGRAM' in env) {
151
159
  const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
152
160
 
@@ -511,11 +519,10 @@ function isWide(x) {
511
519
  || x >= 0xFE54 && x <= 0xFE66
512
520
  || x >= 0xFE68 && x <= 0xFE6B
513
521
  || x >= 0x16FE0 && x <= 0x16FE4
514
- || x === 0x16FF0
515
- || x === 0x16FF1
516
- || x >= 0x17000 && x <= 0x187F7
517
- || x >= 0x18800 && x <= 0x18CD5
518
- || x >= 0x18CFF && x <= 0x18D08
522
+ || x >= 0x16FF0 && x <= 0x16FF6
523
+ || x >= 0x17000 && x <= 0x18CD5
524
+ || x >= 0x18CFF && x <= 0x18D1E
525
+ || x >= 0x18D80 && x <= 0x18DF2
519
526
  || x >= 0x1AFF0 && x <= 0x1AFF3
520
527
  || x >= 0x1AFF5 && x <= 0x1AFFB
521
528
  || x === 0x1AFFD
@@ -560,7 +567,7 @@ function isWide(x) {
560
567
  || x >= 0x1F680 && x <= 0x1F6C5
561
568
  || x === 0x1F6CC
562
569
  || x >= 0x1F6D0 && x <= 0x1F6D2
563
- || x >= 0x1F6D5 && x <= 0x1F6D7
570
+ || x >= 0x1F6D5 && x <= 0x1F6D8
564
571
  || x >= 0x1F6DC && x <= 0x1F6DF
565
572
  || x === 0x1F6EB
566
573
  || x === 0x1F6EC
@@ -571,11 +578,12 @@ function isWide(x) {
571
578
  || x >= 0x1F93C && x <= 0x1F945
572
579
  || x >= 0x1F947 && x <= 0x1F9FF
573
580
  || x >= 0x1FA70 && x <= 0x1FA7C
574
- || x >= 0x1FA80 && x <= 0x1FA89
575
- || x >= 0x1FA8F && x <= 0x1FAC6
576
- || x >= 0x1FACE && x <= 0x1FADC
577
- || x >= 0x1FADF && x <= 0x1FAE9
578
- || x >= 0x1FAF0 && x <= 0x1FAF8
581
+ || x >= 0x1FA80 && x <= 0x1FA8A
582
+ || x >= 0x1FA8E && x <= 0x1FAC6
583
+ || x === 0x1FAC8
584
+ || x >= 0x1FACD && x <= 0x1FADC
585
+ || x >= 0x1FADF && x <= 0x1FAEA
586
+ || x >= 0x1FAEF && x <= 0x1FAF8
579
587
  || x >= 0x20000 && x <= 0x2FFFD
580
588
  || x >= 0x30000 && x <= 0x3FFFD;
581
589
  }
@@ -492,6 +492,11 @@ const detailsFromFirstReference = (reference) => {
492
492
  ) {
493
493
  return {};
494
494
  }
495
+ if (referenceInProject.type === "entry_point") {
496
+ return {
497
+ "first reference": referenceInProject.trace.message,
498
+ };
499
+ }
495
500
  return {
496
501
  "first reference in project": `${referenceInProject.trace.url}:${referenceInProject.trace.line}:${referenceInProject.trace.column}`,
497
502
  };
@@ -2951,6 +2956,7 @@ const createKitchen = ({
2951
2956
  dev = false,
2952
2957
  build = false,
2953
2958
  runtimeCompat,
2959
+ mode,
2954
2960
 
2955
2961
  ignore,
2956
2962
  ignoreProtocol = "remove",
@@ -3000,7 +3006,10 @@ const createKitchen = ({
3000
3006
  }
3001
3007
 
3002
3008
  if (packageDependencies === "auto") {
3003
- packageDependencies = build && nodeRuntimeEnabled ? "ignore" : "include";
3009
+ packageDependencies =
3010
+ build && (nodeRuntimeEnabled || mode === "package")
3011
+ ? "ignore"
3012
+ : "include";
3004
3013
  }
3005
3014
 
3006
3015
  const kitchen = {
@@ -3387,7 +3396,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
3387
3396
  `no plugin has handled url during "fetchUrlContent" hook -> url will be ignored`,
3388
3397
  {
3389
3398
  "url": urlInfo.url,
3390
- "url reference trace": urlInfo.firstReference.trace.message,
3399
+ "url reference trace": urlInfo.firstReference?.trace.message,
3391
3400
  },
3392
3401
  ),
3393
3402
  );
@@ -4742,7 +4751,7 @@ const jsenvPluginHtmlReferenceAnalysis = ({
4742
4751
  const createInlineReference = (
4743
4752
  node,
4744
4753
  inlineContent,
4745
- { type, expectedType, contentType },
4754
+ { type, subtype, expectedType, contentType },
4746
4755
  ) => {
4747
4756
  const hotAccept =
4748
4757
  getHtmlNodeAttribute(node, "hot-accept") !== undefined;
@@ -4758,6 +4767,7 @@ const jsenvPluginHtmlReferenceAnalysis = ({
4758
4767
  getHtmlNodeAttribute(node, "jsenv-debug") !== undefined;
4759
4768
  const inlineReference = urlInfo.dependencies.foundInline({
4760
4769
  type,
4770
+ subtype,
4761
4771
  expectedType,
4762
4772
  isOriginalPosition: isOriginal,
4763
4773
  specifierLine: line,
@@ -5634,7 +5644,6 @@ const createNodeEsmResolver = ({
5634
5644
  const resolveNodeEsmFallbackNullToDelegateToWebPlugin =
5635
5645
  createResolverWithFallbackOnError(
5636
5646
  applyNodeEsmResolution,
5637
-
5638
5647
  () => DELEGATE_TO_WEB_RESOLUTION_PLUGIN,
5639
5648
  );
5640
5649
 
@@ -6050,7 +6059,6 @@ const jsenvPluginNodeEsmResolution = (
6050
6059
  );
6051
6060
  }
6052
6061
  return createNodeEsmResolver({
6053
- build: kitchenContext.build,
6054
6062
  runtimeCompat: kitchenContext.runtimeCompat,
6055
6063
  rootDirectoryUrl: kitchenContext.rootDirectoryUrl,
6056
6064
  packageConditions,
@@ -6067,7 +6075,6 @@ const jsenvPluginNodeEsmResolution = (
6067
6075
  appliesDuring: "*",
6068
6076
  init: (kitchenContext) => {
6069
6077
  nodeEsmResolverDefault = createNodeEsmResolver({
6070
- build: kitchenContext.build,
6071
6078
  runtimeCompat: kitchenContext.runtimeCompat,
6072
6079
  rootDirectoryUrl: kitchenContext.rootDirectoryUrl,
6073
6080
  preservesSymlink: true,
@@ -6910,6 +6917,10 @@ const jsenvPluginProtocolFile = ({
6910
6917
  return null;
6911
6918
  }
6912
6919
  const { firstReference } = urlInfo;
6920
+ if (!firstReference) {
6921
+ console.warn("No firstReference for", urlInfo.url);
6922
+ return null;
6923
+ }
6913
6924
  let { fsStat } = firstReference;
6914
6925
  if (!fsStat) {
6915
6926
  fsStat = readEntryStatSync(urlInfo.url, { nullIfNotFound: true });
@@ -6938,6 +6949,9 @@ const jsenvPluginProtocolFile = ({
6938
6949
  return null;
6939
6950
  }
6940
6951
  const { firstReference } = urlInfo;
6952
+ if (!firstReference) {
6953
+ return null;
6954
+ }
6941
6955
  let { fsStat } = firstReference;
6942
6956
  if (!fsStat) {
6943
6957
  fsStat = readEntryStatSync(urlInfo.url, { nullIfNotFound: true });
@@ -7396,7 +7410,7 @@ const jsenvPluginInliningIntoHtml = () => {
7396
7410
  });
7397
7411
  });
7398
7412
  };
7399
- const onScriptWithSrc = (scriptNode, { src }) => {
7413
+ const onScriptWithSrc = (scriptNode, { type, src }) => {
7400
7414
  let scriptReference;
7401
7415
  for (const dependencyReference of urlInfo.referenceToOthersSet) {
7402
7416
  if (
@@ -7423,7 +7437,7 @@ const jsenvPluginInliningIntoHtml = () => {
7423
7437
  column,
7424
7438
  isOriginal,
7425
7439
  specifier: scriptInlineUrl,
7426
- type: scriptReference.type,
7440
+ type,
7427
7441
  subtype: scriptReference.subtype,
7428
7442
  expectedType: scriptReference.expectedType,
7429
7443
  });
@@ -7467,7 +7481,7 @@ const jsenvPluginInliningIntoHtml = () => {
7467
7481
  if (!src) {
7468
7482
  return;
7469
7483
  }
7470
- onScriptWithSrc(scriptNode, { src });
7484
+ onScriptWithSrc(scriptNode, { type, src });
7471
7485
  },
7472
7486
  });
7473
7487
  if (actions.length > 0) {
@@ -7844,7 +7858,10 @@ const jsenvPluginNodeRuntime = ({ runtimeCompat }) => {
7844
7858
 
7845
7859
  const jsenvPluginImportMetaCss = () => {
7846
7860
  const importMetaCssClientFileUrl = import.meta.resolve(
7847
- "../js/import_meta_css.js",
7861
+ "../client/import_meta_css/import_meta_css.js",
7862
+ );
7863
+ const importMetaCssBuildFileUrl = import.meta.resolve(
7864
+ "../client/import_meta_css/import_meta_css_build.js",
7848
7865
  );
7849
7866
 
7850
7867
  return {
@@ -7866,35 +7883,17 @@ const jsenvPluginImportMetaCss = () => {
7866
7883
  if (!usesImportMetaCss) {
7867
7884
  return null;
7868
7885
  }
7869
- return injectImportMetaCss(urlInfo, importMetaCssClientFileUrl);
7886
+ return injectImportMetaCss(
7887
+ urlInfo,
7888
+ urlInfo.context.build
7889
+ ? importMetaCssBuildFileUrl
7890
+ : importMetaCssClientFileUrl,
7891
+ );
7870
7892
  },
7871
7893
  },
7872
7894
  };
7873
7895
  };
7874
7896
 
7875
- const injectImportMetaCss = (urlInfo, importMetaCssClientFileUrl) => {
7876
- const importMetaCssClientFileReference = urlInfo.dependencies.inject({
7877
- parentUrl: urlInfo.url,
7878
- type: "js_import",
7879
- expectedType: "js_module",
7880
- specifier: importMetaCssClientFileUrl,
7881
- });
7882
- let content = urlInfo.content;
7883
- let prelude = `import { installImportMetaCss } from ${importMetaCssClientFileReference.generatedSpecifier};
7884
-
7885
- const remove = installImportMetaCss(import.meta);
7886
- if (import.meta.hot) {
7887
- import.meta.hot.dispose(() => {
7888
- remove();
7889
- });
7890
- }
7891
-
7892
- `;
7893
- return {
7894
- content: `${prelude.replace(/\n/g, "")}${content}`,
7895
- };
7896
- };
7897
-
7898
7897
  const babelPluginMetadataUsesImportMetaCss = () => {
7899
7898
  return {
7900
7899
  name: "metadata-uses-import-meta-css",
@@ -7926,6 +7925,29 @@ const babelPluginMetadataUsesImportMetaCss = () => {
7926
7925
  };
7927
7926
  };
7928
7927
 
7928
+ const injectImportMetaCss = (urlInfo, importMetaCssClientFileUrl) => {
7929
+ const importMetaCssClientFileReference = urlInfo.dependencies.inject({
7930
+ parentUrl: urlInfo.url,
7931
+ type: "js_import",
7932
+ expectedType: "js_module",
7933
+ specifier: importMetaCssClientFileUrl,
7934
+ });
7935
+ let content = urlInfo.content;
7936
+ let prelude = `import { installImportMetaCss } from ${importMetaCssClientFileReference.generatedSpecifier};
7937
+
7938
+ const remove = installImportMetaCss(import.meta);
7939
+ if (import.meta.hot) {
7940
+ import.meta.hot.dispose(() => {
7941
+ remove();
7942
+ });
7943
+ }
7944
+
7945
+ `;
7946
+ return {
7947
+ content: `${prelude.replace(/\n/g, "")}${content}`,
7948
+ };
7949
+ };
7950
+
7929
7951
  // https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md#toc-stages-of-babel
7930
7952
  // https://github.com/cfware/babel-plugin-bundled-import-meta/blob/master/index.js
7931
7953
  // https://github.com/babel/babel/blob/f4edf62f6beeab8ae9f2b7f0b82f1b3b12a581af/packages/babel-helper-module-imports/src/index.js#L7
@@ -8872,7 +8894,7 @@ const jsenvPluginRibbon = ({
8872
8894
 
8873
8895
 
8874
8896
  const jsenvPluginDropToOpen = () => {
8875
- const clientFileUrl = import.meta.resolve("../js/drop_to_open.js");
8897
+ const clientFileUrl = import.meta.resolve("../client/drop_to_open/drop_to_open.js");
8876
8898
  return {
8877
8899
  name: "jsenv:drop_to_open",
8878
8900
  appliesDuring: "dev",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "40.9.1",
3
+ "version": "40.11.0",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -75,17 +75,18 @@
75
75
  },
76
76
  "dependencies": {
77
77
  "@financial-times/polyfill-useragent-normaliser": "1.10.2",
78
- "@jsenv/ast": "6.7.13",
79
- "@jsenv/js-module-fallback": "1.4.21",
80
- "@jsenv/plugin-bundling": "2.9.12",
78
+ "@jsenv/ast": "6.7.14",
79
+ "@jsenv/js-module-fallback": "1.4.22",
80
+ "@jsenv/plugin-bundling": "2.10.1",
81
81
  "@jsenv/plugin-minification": "1.7.2",
82
- "@jsenv/plugin-supervisor": "1.7.6",
83
- "@jsenv/plugin-transpilation": "1.5.59",
84
- "@jsenv/server": "16.3.1",
82
+ "@jsenv/plugin-supervisor": "1.7.8",
83
+ "@jsenv/plugin-transpilation": "1.5.61",
84
+ "@jsenv/server": "16.3.2",
85
85
  "@jsenv/sourcemap": "1.3.10",
86
86
  "react-table": "7.8.0"
87
87
  },
88
88
  "devDependencies": {
89
+ "@babel/eslint-parser": "7.28.4",
89
90
  "@babel/plugin-syntax-decorators": "7.27.1",
90
91
  "@babel/plugin-syntax-import-attributes": "7.27.1",
91
92
  "@babel/plugin-syntax-optional-chaining-assign": "7.27.1",
@@ -115,29 +116,34 @@
115
116
  "@jsenv/url-meta": "workspace:*",
116
117
  "@jsenv/urls": "workspace:*",
117
118
  "@jsenv/utils": "workspace:*",
118
- "@playwright/browser-chromium": "1.54.1",
119
- "@playwright/browser-firefox": "1.54.1",
120
- "@playwright/browser-webkit": "1.54.1",
119
+ "@playwright/browser-chromium": "1.56.1",
120
+ "@playwright/browser-firefox": "1.56.1",
121
+ "@playwright/browser-webkit": "1.56.1",
121
122
  "babel-plugin-transform-async-to-promises": "0.8.18",
122
- "eslint": "9.32.0",
123
+ "eslint": "9.38.0",
124
+ "eslint-plugin-html": "8.1.3",
125
+ "eslint-plugin-import-x": "4.16.1",
126
+ "eslint-plugin-react": "7.37.5",
127
+ "eslint-plugin-regexp": "2.10.0",
128
+ "globals": "16.4.0",
123
129
  "open": "10.2.0",
124
- "playwright": "1.54.1",
125
- "preact": "10.27.0",
126
- "preact-iso": "2.9.2",
130
+ "playwright": "1.56.1",
131
+ "preact": "10.27.2",
127
132
  "prettier": "3.6.2",
133
+ "prettier-plugin-css-order": "git+https://github.com/dmail-fork/prettier-plugin-css-order.git",
128
134
  "prettier-plugin-embed": "0.5.0",
129
- "prettier-plugin-organize-imports": "4.2.0",
135
+ "prettier-plugin-organize-imports": "4.3.0",
130
136
  "prettier-plugin-packagejson": "2.5.19",
131
137
  "prettier-plugin-sql": "0.19.2",
132
- "strip-ansi": "7.1.0"
138
+ "strip-ansi": "7.1.2"
133
139
  },
134
140
  "packageManager": "npm@11.3.0",
135
141
  "engines": {
136
142
  "node": ">=20.8.0"
137
143
  },
138
144
  "volta": {
139
- "node": "24.1.0",
140
- "npm": "11.3.0"
145
+ "node": "25.1.0",
146
+ "npm": "11.6.2"
141
147
  },
142
148
  "publishConfig": {
143
149
  "access": "public"
@@ -87,31 +87,60 @@ import { jsenvPluginMappings } from "./jsenv_plugin_mappings.js";
87
87
  * @param {string|url} params.buildDirectoryUrl
88
88
  * Directory where optimized files will be written
89
89
  * @param {object} params.entryPoints
90
- * Object where keys are paths to source files and values are their future name in the build directory.
91
- * Keys are relative to sourceDirectoryUrl
92
- * @param {object} params.runtimeCompat
93
- * Code generated will be compatible with these runtimes
94
- * @param {string} [params.assetsDirectory]
95
- * Directory where asset files will be written. By default sibling to the entry build file.
96
- * @param {string|url} [params.base=""]
97
- * Urls in build file contents will be prefixed with this string
98
- * @param {boolean|object} [params.bundling=true]
99
- * Reduce number of files written in the build directory
100
- * @param {boolean|object} [params.minification=true]
101
- * Minify the content of files written into the build directory
102
- * @param {boolean} [params.versioning=true]
103
- * Use versioning on files written in the build directory
104
- * @param {('search_param'|'filename')} [params.versioningMethod="search_param"]
105
- * Controls how url are versioned in the build directory
106
- * @param {('none'|'inline'|'file'|'programmatic')} [params.sourcemaps="none"]
107
- * Generate sourcemaps in the build directory
108
- * @param {('error'|'copy'|'preserve')|function} [params.directoryReferenceEffect="error"]
109
- * What to do when a reference leads to a directory on the filesystem
90
+ * Object where keys are paths to source files and values are configuration objects for each entry point.
91
+ * Keys are relative to sourceDirectoryUrl or bare specifiers
92
+ * @param {object} [params.logs]
93
+ * Configuration for build logging
94
+ * @param {string|url} [params.outDirectoryUrl]
95
+ * Directory for temporary build files and cache
96
+ * @param {object} [params.buildDirectoryCleanPatterns]
97
+ * Patterns for files to clean from build directory before building (defaults to all files)
98
+ * @param {boolean} [params.returnBuildInlineContents]
99
+ * Whether to return inline contents in the result
100
+ * @param {boolean} [params.returnBuildManifest]
101
+ * Whether to return build manifest in the result
102
+ * @param {boolean} [params.returnBuildFileVersions]
103
+ * Whether to return file versions in the result
104
+ * @param {AbortSignal} [params.signal]
105
+ * Signal to abort the build process
106
+ * @param {boolean} [params.handleSIGINT=true]
107
+ * Whether to handle SIGINT for graceful shutdown
108
+ * @param {boolean} [params.writeOnFileSystem=true]
109
+ * Whether to write build files to the filesystem
110
+ * @param {boolean} [params.watch=false]
111
+ * Whether to enable watch mode for continuous building
112
+ * @param {object} [params.sourceFilesConfig]
113
+ * Configuration for source file watching
114
+ * @param {number} [params.cooldownBetweenFileEvents]
115
+ * Cooldown time between file change events in watch mode
116
+ *
117
+ * Entry point configuration (values in params.entryPoints):
118
+ * @param {string} [entryPoint.buildRelativeUrl]
119
+ * Relative URL where this entry point will be written in the build directory
120
+ * @param {object} [entryPoint.runtimeCompat]
121
+ * Runtime compatibility configuration for this entry point
122
+ * @param {string} [entryPoint.assetsDirectory]
123
+ * Directory where asset files will be written for this entry point
124
+ * @param {string|url} [entryPoint.base]
125
+ * Base URL prefix for references in this entry point
126
+ * @param {boolean|object} [entryPoint.bundling=true]
127
+ * Whether to enable bundling for this entry point
128
+ * @param {boolean|object} [entryPoint.minification=true]
129
+ * Whether to enable minification for this entry point
130
+ * @param {boolean} [entryPoint.versioning=true]
131
+ * Whether to enable versioning for this entry point
132
+ * @param {('search_param'|'filename')} [entryPoint.versioningMethod]
133
+ * How URLs are versioned for this entry point (defaults to "search_param")
134
+ * @param {('none'|'inline'|'file'|'programmatic')} [entryPoint.sourcemaps]
135
+ * Sourcemap generation strategy for this entry point (defaults to "none")
136
+ *
110
137
  * @return {Promise<Object>} buildReturnValue
111
- * @return {Promise<Object>} buildReturnValue.buildInlineContents
112
- * Contains content that is inline into build files
113
- * @return {Promise<Object>} buildReturnValue.buildManifest
114
- * Map build file paths without versioning to versioned file paths
138
+ * @return {Promise<Object>} [buildReturnValue.buildInlineContents]
139
+ * Contents that are inlined into build files (if returnBuildInlineContents is true)
140
+ * @return {Promise<Object>} [buildReturnValue.buildManifest]
141
+ * Map of build file paths without versioning to versioned file paths (if returnBuildManifest is true)
142
+ * @return {Promise<Object>} [buildReturnValue.buildFileVersions]
143
+ * Version information for build files (if returnBuildFileVersions is true)
115
144
  */
116
145
  export const build = async ({
117
146
  sourceDirectoryUrl,
@@ -337,7 +366,7 @@ export const build = async ({
337
366
  });
338
367
 
339
368
  const logLevel = logs.level;
340
- const logger = createLogger({ logLevel });
369
+ let logger = createLogger({ logLevel });
341
370
  const animatedLogEnabled =
342
371
  logs.animated &&
343
372
  // canEraseProcessStdout
@@ -819,9 +848,9 @@ export const build = async ({
819
848
  const buildTask = createTaskLog("build");
820
849
  buildAbortController = new AbortController();
821
850
  try {
851
+ logger = createLogger({ logLevel: "warn" });
822
852
  const result = await runBuild({
823
853
  signal: buildAbortController.signal,
824
- logLevel: "warn",
825
854
  });
826
855
  buildTask.done();
827
856
  resolveFirstBuild(result);
@@ -874,6 +903,7 @@ export const build = async ({
874
903
 
875
904
  const entryPointDefaultParams = {
876
905
  buildRelativeUrl: undefined,
906
+ mode: undefined,
877
907
  runtimeCompat: defaultRuntimeCompat,
878
908
  plugins: [],
879
909
  mappings: undefined,
@@ -927,6 +957,7 @@ const prepareEntryPointBuild = async (
927
957
  ) => {
928
958
  let {
929
959
  buildRelativeUrl,
960
+ mode,
930
961
  runtimeCompat,
931
962
  plugins,
932
963
  mappings,
@@ -1001,7 +1032,7 @@ const prepareEntryPointBuild = async (
1001
1032
  assetsDirectory = `${assetsDirectory}/`;
1002
1033
  }
1003
1034
  if (entryPointParams.base === undefined) {
1004
- base = someEntryPointUseNode ? "./" : "/";
1035
+ base = mode === "package" || someEntryPointUseNode ? "./" : "/";
1005
1036
  }
1006
1037
  if (entryPointParams.bundling === undefined) {
1007
1038
  bundling = true;
@@ -1010,13 +1041,21 @@ const prepareEntryPointBuild = async (
1010
1041
  bundling = {};
1011
1042
  }
1012
1043
  if (entryPointParams.minification === undefined) {
1013
- minification = !someEntryPointUseNode;
1044
+ if (mode === "package" || someEntryPointUseNode) {
1045
+ minification = false;
1046
+ } else {
1047
+ minification = true;
1048
+ }
1014
1049
  }
1015
1050
  if (minification === true) {
1016
1051
  minification = {};
1017
1052
  }
1018
1053
  if (entryPointParams.versioning === undefined) {
1019
- versioning = !someEntryPointUseNode;
1054
+ if (mode === "package" || someEntryPointUseNode) {
1055
+ versioning = false;
1056
+ } else {
1057
+ versioning = true;
1058
+ }
1020
1059
  }
1021
1060
  if (entryPointParams.versioningMethod === undefined) {
1022
1061
  versioningMethod = entryPointDefaultParams.versioningMethod;
@@ -1025,7 +1064,14 @@ const prepareEntryPointBuild = async (
1025
1064
  assetManifest = versioningMethod === "filename";
1026
1065
  }
1027
1066
  if (entryPointParams.preserveComments === undefined) {
1028
- preserveComments = someEntryPointUseNode;
1067
+ if (mode === "package" || someEntryPointUseNode) {
1068
+ preserveComments = true;
1069
+ }
1070
+ }
1071
+ if (entryPointParams.sourcemaps === undefined) {
1072
+ if (mode === "package") {
1073
+ sourcemaps = "file";
1074
+ }
1029
1075
  }
1030
1076
  }
1031
1077
 
@@ -1052,6 +1098,7 @@ const prepareEntryPointBuild = async (
1052
1098
  ignoreProtocol: "keep",
1053
1099
  build: true,
1054
1100
  runtimeCompat,
1101
+ mode,
1055
1102
  initialContext: contextSharedDuringBuild,
1056
1103
  sourcemaps,
1057
1104
  sourcemapsSourcesContent,
@@ -1152,6 +1199,7 @@ const prepareEntryPointBuild = async (
1152
1199
  ignoreProtocol: "remove",
1153
1200
  build: true,
1154
1201
  runtimeCompat,
1202
+ mode,
1155
1203
  initialContext: contextSharedDuringBuild,
1156
1204
  sourcemaps,
1157
1205
  sourcemapsComment: "relative",
@@ -316,7 +316,6 @@ export const startDevServer = async ({
316
316
  runtimeCompat,
317
317
  clientRuntimeCompat,
318
318
  supervisor,
319
- minification: false,
320
319
  sourcemaps,
321
320
  sourcemapsSourcesContent,
322
321
  outDirectoryUrl: outDirectoryUrl
@@ -303,6 +303,11 @@ const detailsFromFirstReference = (reference) => {
303
303
  ) {
304
304
  return {};
305
305
  }
306
+ if (referenceInProject.type === "entry_point") {
307
+ return {
308
+ "first reference": referenceInProject.trace.message,
309
+ };
310
+ }
306
311
  return {
307
312
  "first reference in project": `${referenceInProject.trace.url}:${referenceInProject.trace.line}:${referenceInProject.trace.column}`,
308
313
  };
@@ -39,6 +39,7 @@ export const createKitchen = ({
39
39
  dev = false,
40
40
  build = false,
41
41
  runtimeCompat,
42
+ mode,
42
43
 
43
44
  ignore,
44
45
  ignoreProtocol = "remove",
@@ -88,7 +89,10 @@ export const createKitchen = ({
88
89
  }
89
90
 
90
91
  if (packageDependencies === "auto") {
91
- packageDependencies = build && nodeRuntimeEnabled ? "ignore" : "include";
92
+ packageDependencies =
93
+ build && (nodeRuntimeEnabled || mode === "package")
94
+ ? "ignore"
95
+ : "include";
92
96
  }
93
97
 
94
98
  const kitchen = {
@@ -475,7 +479,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
475
479
  `no plugin has handled url during "fetchUrlContent" hook -> url will be ignored`,
476
480
  {
477
481
  "url": urlInfo.url,
478
- "url reference trace": urlInfo.firstReference.trace.message,
482
+ "url reference trace": urlInfo.firstReference?.trace.message,
479
483
  },
480
484
  ),
481
485
  );
@@ -0,0 +1,20 @@
1
+ export const installImportMetaCss = (importMeta) => {
2
+ const stylesheet = new CSSStyleSheet({ baseUrl: importMeta.url });
3
+
4
+ let called = false;
5
+ // eslint-disable-next-line accessor-pairs
6
+ Object.defineProperty(importMeta, "css", {
7
+ configurable: true,
8
+ set(value) {
9
+ if (called) {
10
+ throw new Error("import.meta.css setter can only be called once");
11
+ }
12
+ called = true;
13
+ stylesheet.replaceSync(value);
14
+ document.adoptedStyleSheets = [
15
+ ...document.adoptedStyleSheets,
16
+ stylesheet,
17
+ ];
18
+ },
19
+ });
20
+ };