@jsenv/core 41.0.3 → 41.0.5

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.
@@ -10,7 +10,7 @@ import { generateSourcemapFileUrl, createMagicSource, composeTwoSourcemaps, gene
10
10
  import { createPluginsController } from "@jsenv/server/src/plugins_controller.js";
11
11
  import { jsenvPluginSupervisor } from "@jsenv/plugin-supervisor";
12
12
  import { WebSocketResponse, pickContentType } from "@jsenv/server";
13
- import { randomUUID, createHash } from "node:crypto";
13
+ import { createHash } from "node:crypto";
14
14
  import "./jsenv_core_node_modules.js";
15
15
  import "node:os";
16
16
  import "node:tty";
@@ -3860,7 +3860,11 @@ const jsenvPluginDirectoryReferenceEffect = (
3860
3860
  reference.ownerUrlInfo.filenameHint
3861
3861
  }${urlToFilename(reference.url)}/`;
3862
3862
  } else if (reference.specifierPathname.endsWith("./")) ; else {
3863
- reference.filenameHint = `${urlToFilename(reference.url)}/`;
3863
+ const directoryRelativeUrl = urlToRelativeUrl(
3864
+ reference.url,
3865
+ reference.ownerUrlInfo.originalUrl,
3866
+ );
3867
+ reference.filenameHint = directoryRelativeUrl;
3864
3868
  }
3865
3869
  let actionForDirectory;
3866
3870
  if (reference.type === "a_href") {
@@ -7497,6 +7501,14 @@ const jsenvPluginImportMetaScenarios = () => {
7497
7501
  appliesDuring: "*",
7498
7502
  transformUrlContent: {
7499
7503
  js_module: async (urlInfo) => {
7504
+ // Do not scan node modules for import.meta.dev/import.meta.build
7505
+ // - node modules won't have this in their code
7506
+ // - ;or should use other an other technic as this one won't be available
7507
+ // They would be discarded by content.includes detection
7508
+ // but it's cheaper to detect by URL than to scan potentially large files
7509
+ if (urlInfo.url.includes("/node_modules/")) {
7510
+ return null;
7511
+ }
7500
7512
  if (
7501
7513
  !urlInfo.content.includes("import.meta.dev") &&
7502
7514
  !urlInfo.content.includes("import.meta.test") &&
@@ -7593,6 +7605,14 @@ const babelPluginMetadataImportMetaScenarios = () => {
7593
7605
 
7594
7606
  const jsenvPluginGlobalScenarios = () => {
7595
7607
  const transformIfNeeded = (urlInfo) => {
7608
+ // Do not scan node modules for __DEV__/__BUILD__
7609
+ // - node modules won't have this in their code
7610
+ // - ;or should use other an other technic as this one won't be available
7611
+ // They would be discarded by content.includes detection
7612
+ // but it's cheaper to detect by URL than to scan potentially large files
7613
+ if (urlInfo.url.includes("/node_modules/")) {
7614
+ return null;
7615
+ }
7596
7616
  return {
7597
7617
  contentInjections: {
7598
7618
  __DEV__: INJECTIONS.optional(urlInfo.context.dev),
@@ -7662,6 +7682,14 @@ const jsenvPluginImportMetaCss = () => {
7662
7682
  appliesDuring: "*",
7663
7683
  transformUrlContent: {
7664
7684
  js_module: async (urlInfo) => {
7685
+ // Do not scan node modules for import.meta.css
7686
+ // - unlikely to be there
7687
+ // - we don't watch node modules (too expensive)
7688
+ // They would be discarded by content.includes detection
7689
+ // but it's cheaper to detect by URL than to scan potentially large files
7690
+ if (urlInfo.url.includes("/node_modules/")) {
7691
+ return null;
7692
+ }
7665
7693
  if (!urlInfo.content.includes("import.meta.css")) {
7666
7694
  return null;
7667
7695
  }
@@ -8120,6 +8148,14 @@ const jsenvPluginImportMetaHot = () => {
8120
8148
  cssUrlInfo.data.hotAcceptDependencies = [];
8121
8149
  },
8122
8150
  js_module: async (urlInfo) => {
8151
+ // Do not scan node modules for import.meta.hot
8152
+ // - unlikely to be there
8153
+ // - we don't watch node modules (too expensive)
8154
+ // They would be discarded by content.includes detection
8155
+ // but it's cheaper to detect by URL than to scan potentially large files
8156
+ if (urlInfo.url.includes("/node_modules/")) {
8157
+ return null;
8158
+ }
8123
8159
  if (!urlInfo.content.includes("import.meta.hot")) {
8124
8160
  return null;
8125
8161
  }
@@ -8823,47 +8859,6 @@ const jsenvPluginCleanHTML = () => {
8823
8859
  };
8824
8860
  };
8825
8861
 
8826
- /**
8827
- * https://docs.google.com/document/d/1rfKPnxsNuXhnF7AiQZhu9kIwdiMS5hnAI05HBwFuBSM/edit?tab=t.0#heading=h.7nki9mck5t64
8828
- * https://chromium.googlesource.com/devtools/devtools-frontend/+/main/docs/ecosystem/automatic_workspace_folders.md
8829
- * https://github.com/ChromeDevTools/vite-plugin-devtools-json
8830
- */
8831
-
8832
-
8833
- const jsenvPluginChromeDevtoolsJson = () => {
8834
- const getOrCreateUUID = (kitchen) => {
8835
- const { outDirectoryUrl } = kitchen.context;
8836
- const uuidFileUrl = new URL("./uuid.json", outDirectoryUrl);
8837
- if (existsSync(uuidFileUrl)) {
8838
- const { uuid } = JSON.parse(readFileSync(uuidFileUrl, "utf8"));
8839
- return uuid;
8840
- }
8841
- const uuid = randomUUID();
8842
- writeFileSync(uuidFileUrl, JSON.stringify({ uuid }), { });
8843
- return uuid;
8844
- };
8845
-
8846
- return {
8847
- name: "jsenv_plugin_chrome_devtools_json",
8848
- appliesDuring: "dev",
8849
- serverRoutes: [
8850
- {
8851
- endpoint: "GET /.well-known/appspecific/com.chrome.devtools.json",
8852
- declarationSource: import.meta.url,
8853
- fetch: (request, { kitchen }) => {
8854
- const { rootDirectoryUrl } = kitchen.context;
8855
- return Response.json({
8856
- workspace: {
8857
- root: urlToFileSystemPath(rootDirectoryUrl),
8858
- uuid: getOrCreateUUID(kitchen),
8859
- },
8860
- });
8861
- },
8862
- },
8863
- ],
8864
- };
8865
- };
8866
-
8867
8862
  const jsenvPluginAutoreloadOnServerRestart = () => {
8868
8863
  const autoreloadOnRestartClientFileUrl = import.meta
8869
8864
  .resolve("@jsenv/server/src/plugins/autoreload_on_server_restart/client/autoreload_on_server_restart.js");
@@ -9308,7 +9303,6 @@ const getCorePlugins = ({
9308
9303
  ...(ribbon ? [jsenvPluginRibbon({ rootDirectoryUrl, ...ribbon })] : []),
9309
9304
  ...(dropToOpen ? [jsenvPluginDropToOpen()] : []),
9310
9305
  jsenvPluginCleanHTML(),
9311
- jsenvPluginChromeDevtoolsJson(),
9312
9306
  ...(packageSideEffects
9313
9307
  ? [jsenvPluginPackageSideEffects({ packageDirectory })]
9314
9308
  : []),