@cloudflare/vite-plugin 0.1.8 → 0.1.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.
package/dist/index.js CHANGED
@@ -1370,6 +1370,7 @@ import {
1370
1370
  LogLevel,
1371
1371
  Response as MiniflareResponse
1372
1372
  } from "miniflare";
1373
+ import { globSync } from "tinyglobby";
1373
1374
  import "vite";
1374
1375
  import {
1375
1376
  unstable_getMiniflareWorkerOptions,
@@ -1713,6 +1714,26 @@ function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer) {
1713
1714
  }
1714
1715
  };
1715
1716
  }
1717
+ function getPreviewModules(main, modulesRules) {
1718
+ assert4(modulesRules, `Unexpected error: 'modulesRules' is undefined`);
1719
+ const rootPath = path3.dirname(main);
1720
+ const entryPath = path3.basename(main);
1721
+ return {
1722
+ rootPath,
1723
+ modules: [
1724
+ {
1725
+ type: "ESModule",
1726
+ path: entryPath
1727
+ },
1728
+ ...modulesRules.flatMap(
1729
+ ({ type, include }) => globSync(include, { cwd: rootPath, ignore: entryPath }).map((path8) => ({
1730
+ type,
1731
+ path: path8
1732
+ }))
1733
+ )
1734
+ ]
1735
+ };
1736
+ }
1716
1737
  function getPreviewMiniflareOptions(vitePreviewServer, persistState) {
1717
1738
  const resolvedViteConfig = vitePreviewServer.config;
1718
1739
  const configPaths = getWorkerConfigPaths(resolvedViteConfig.root);
@@ -1721,13 +1742,12 @@ function getPreviewMiniflareOptions(vitePreviewServer, persistState) {
1721
1742
  );
1722
1743
  const workers = workerConfigs.map((config) => {
1723
1744
  const miniflareWorkerOptions = unstable_getMiniflareWorkerOptions(config);
1724
- const { ratelimits, ...workerOptions } = miniflareWorkerOptions.workerOptions;
1745
+ const { ratelimits, modulesRules, ...workerOptions } = miniflareWorkerOptions.workerOptions;
1725
1746
  return {
1726
1747
  ...workerOptions,
1727
1748
  // We have to add the name again because `unstable_getMiniflareWorkerOptions` sets it to `undefined`
1728
1749
  name: config.name,
1729
- modules: true,
1730
- ...miniflareWorkerOptions.main ? { scriptPath: miniflareWorkerOptions.main } : { script: "" }
1750
+ ...miniflareWorkerOptions.main ? getPreviewModules(miniflareWorkerOptions.main, modulesRules) : { modules: true, script: "" }
1731
1751
  };
1732
1752
  });
1733
1753
  const logger = new ViteMiniflareLogger(resolvedViteConfig);
@@ -7370,7 +7390,7 @@ var isAbsolute = function(p) {
7370
7390
  import { fileURLToPath as fileURLToPath$1, URL as URL$1, pathToFileURL as pathToFileURL$1 } from "node:url";
7371
7391
  import assert5 from "node:assert";
7372
7392
  import process$1 from "node:process";
7373
- import path4, { dirname as dirname3 } from "node:path";
7393
+ import path4, { dirname as dirname4 } from "node:path";
7374
7394
  import v8 from "node:v8";
7375
7395
  import { format as format2, inspect } from "node:util";
7376
7396
  var BUILTIN_MODULES = new Set(builtinModules);
@@ -9309,7 +9329,7 @@ function cloudflare2(pluginConfig = {}) {
9309
9329
  return;
9310
9330
  }
9311
9331
  config.no_bundle = true;
9312
- config.rules = [{ type: "ESModule", globs: ["**/*.js"] }];
9332
+ config.rules = [{ type: "ESModule", globs: ["**/*.js", "**/*.mjs"] }];
9313
9333
  if (config.unsafe && Object.keys(config.unsafe).length === 0) {
9314
9334
  config.unsafe = void 0;
9315
9335
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/vite-plugin",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Cloudflare plugin for Vite",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -35,12 +35,13 @@
35
35
  "dependencies": {
36
36
  "@cloudflare/unenv-preset": "1.1.1",
37
37
  "@hattip/adapter-node": "^0.0.49",
38
+ "tinyglobby": "^0.2.12",
38
39
  "unenv": "2.0.0-rc.1",
39
40
  "ws": "8.18.0",
40
- "miniflare": "3.20250214.2"
41
+ "miniflare": "3.20250224.0"
41
42
  },
42
43
  "devDependencies": {
43
- "@cloudflare/workers-types": "^4.20250214.0",
44
+ "@cloudflare/workers-types": "^4.20250224.0",
44
45
  "@types/node": "^22.10.1",
45
46
  "@types/ws": "^8.5.13",
46
47
  "magic-string": "^0.30.12",
@@ -50,10 +51,10 @@
50
51
  "undici": "^5.28.5",
51
52
  "vite": "^6.1.0",
52
53
  "vitest": "~3.0.5",
53
- "@cloudflare/workers-shared": "0.14.4",
54
54
  "@cloudflare/mock-npm-registry": "0.0.0",
55
- "wrangler": "3.112.0",
56
- "@cloudflare/workers-tsconfig": "0.0.0"
55
+ "@cloudflare/workers-shared": "0.14.5",
56
+ "@cloudflare/workers-tsconfig": "0.0.0",
57
+ "wrangler": "3.113.0"
57
58
  },
58
59
  "peerDependencies": {
59
60
  "vite": "^6.1.0",