@adonisjs/vite 3.0.0-8 → 3.0.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.
@@ -1,4 +1,4 @@
1
- // src/middleware/vite_middleware.ts
1
+ // src/vite_middleware.ts
2
2
  var ViteMiddleware = class {
3
3
  constructor(vite) {
4
4
  this.vite = vite;
@@ -6,7 +6,11 @@ var ViteMiddleware = class {
6
6
  }
7
7
  #devServer;
8
8
  async handle({ request, response }, next) {
9
- return await new Promise((resolve) => {
9
+ if (!this.#devServer)
10
+ return next();
11
+ if (this.#devServer.config.server.cors === false)
12
+ response.relayHeaders();
13
+ await new Promise((resolve) => {
10
14
  this.#devServer.middlewares.handle(request.request, response.response, () => {
11
15
  return resolve(next());
12
16
  });
@@ -17,4 +21,4 @@ var ViteMiddleware = class {
17
21
  export {
18
22
  ViteMiddleware
19
23
  };
20
- //# sourceMappingURL=chunk-MQRASPMO.js.map
24
+ //# sourceMappingURL=chunk-G4LGE4JY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vite_middleware.ts"],"sourcesContent":["/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type { ViteDevServer } from 'vite'\nimport type { HttpContext } from '@adonisjs/core/http'\nimport type { NextFn } from '@adonisjs/core/types/http'\n\nimport type { Vite } from './vite.js'\n\n/**\n * Since Vite dev server is integrated within the AdonisJS process, this\n * middleware is used to proxy the requests to it.\n *\n * Some of the requests are directly handled by the Vite dev server,\n * like the one for the assets, while others are passed down to the\n * AdonisJS server.\n */\nexport default class ViteMiddleware {\n #devServer: ViteDevServer\n\n constructor(protected vite: Vite) {\n this.#devServer = this.vite.getDevServer()!\n }\n\n async handle({ request, response }: HttpContext, next: NextFn) {\n if (!this.#devServer) return next()\n\n /**\n * @adonisjs/cors should handle the CORS instead of Vite\n */\n if (this.#devServer.config.server.cors === false) response.relayHeaders()\n\n /**\n * Proxy the request to the vite dev server\n */\n await new Promise((resolve) => {\n this.#devServer.middlewares.handle(request.request, response.response, () => {\n return resolve(next())\n })\n })\n }\n}\n"],"mappings":";AAuBA,IAAqB,iBAArB,MAAoC;AAAA,EAGlC,YAAsB,MAAY;AAAZ;AACpB,SAAK,aAAa,KAAK,KAAK,aAAa;AAAA,EAC3C;AAAA,EAJA;AAAA,EAMA,MAAM,OAAO,EAAE,SAAS,SAAS,GAAgB,MAAc;AAC7D,QAAI,CAAC,KAAK;AAAY,aAAO,KAAK;AAKlC,QAAI,KAAK,WAAW,OAAO,OAAO,SAAS;AAAO,eAAS,aAAa;AAKxE,UAAM,IAAI,QAAQ,CAAC,YAAY;AAC7B,WAAK,WAAW,YAAY,OAAO,QAAQ,SAAS,SAAS,UAAU,MAAM;AAC3E,eAAO,QAAQ,KAAK,CAAC;AAAA,MACvB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -4,7 +4,10 @@ import {
4
4
  } from "./chunk-CFRBPZ4N.js";
5
5
 
6
6
  // src/vite.ts
7
+ import { join } from "node:path";
7
8
  import { readFileSync } from "node:fs";
9
+ import { slash } from "@poppinss/utils";
10
+ var styleFileRegex = /\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\?)/;
8
11
  var Vite = class {
9
12
  constructor(isViteRunning, options) {
10
13
  this.isViteRunning = isViteRunning;
@@ -18,6 +21,7 @@ var Vite = class {
18
21
  #manifestCache;
19
22
  #options;
20
23
  #devServer;
24
+ #createServerPromise;
21
25
  /**
22
26
  * Reads the file contents as JSON
23
27
  */
@@ -57,7 +61,16 @@ var Vite = class {
57
61
  * Check if the given path is a CSS path
58
62
  */
59
63
  #isCssPath(path) {
60
- return path.match(/\.(css|less|sass|scss|styl|stylus|pcss|postcss)$/) !== null;
64
+ return path.match(styleFileRegex) !== null;
65
+ }
66
+ /**
67
+ * If the module is a style module
68
+ */
69
+ #isStyleModule(mod) {
70
+ if (this.#isCssPath(mod.url) || mod.id && /\?vue&type=style/.test(mod.id)) {
71
+ return true;
72
+ }
73
+ return false;
61
74
  }
62
75
  /**
63
76
  * Unwrap attributes from the user defined function or return
@@ -111,15 +124,58 @@ var Vite = class {
111
124
  }
112
125
  return this.#makeScriptTag(asset, url, attributes);
113
126
  }
127
+ /**
128
+ * Collect CSS files from the module graph recursively
129
+ */
130
+ #collectCss(mod, styleUrls, visitedModules, importer) {
131
+ if (!mod.url)
132
+ return;
133
+ if (visitedModules.has(mod.url))
134
+ return;
135
+ visitedModules.add(mod.url);
136
+ if (this.#isStyleModule(mod) && (!importer || !this.#isStyleModule(importer))) {
137
+ if (mod.url.startsWith("/")) {
138
+ styleUrls.add(mod.url);
139
+ } else if (mod.url.startsWith("\0")) {
140
+ styleUrls.add(`/@id/__x00__${mod.url.substring(1)}`);
141
+ } else {
142
+ styleUrls.add(`/@id/${mod.url}`);
143
+ }
144
+ }
145
+ mod.importedModules.forEach((dep) => this.#collectCss(dep, styleUrls, visitedModules, mod));
146
+ }
114
147
  /**
115
148
  * Generate style and script tags for the given entrypoints
116
149
  * Also adds the @vite/client script
117
150
  */
118
- #generateEntryPointsTagsForDevMode(entryPoints, attributes) {
119
- const viteHmr = this.#getViteHmrScript(attributes);
151
+ async #generateEntryPointsTagsForDevMode(entryPoints, attributes) {
152
+ const server = this.getDevServer();
120
153
  const tags = entryPoints.map((entrypoint) => this.#generateTag(entrypoint, attributes));
121
- const result = viteHmr ? [viteHmr].concat(tags) : tags;
122
- return result;
154
+ const jsEntrypoints = entryPoints.filter((entrypoint) => !this.#isCssPath(entrypoint));
155
+ if (server?.moduleGraph.idToModuleMap.size === 0) {
156
+ await Promise.allSettled(
157
+ jsEntrypoints.map((entrypoint) => server.warmupRequest(`/${entrypoint}`))
158
+ );
159
+ }
160
+ const preloadUrls = /* @__PURE__ */ new Set();
161
+ const visitedModules = /* @__PURE__ */ new Set();
162
+ const cssTagsElement = /* @__PURE__ */ new Set();
163
+ for (const entryPoint of jsEntrypoints) {
164
+ const filePath = join(server.config.root, entryPoint);
165
+ const entryMod = server.moduleGraph.getModuleById(slash(filePath));
166
+ if (entryMod)
167
+ this.#collectCss(entryMod, preloadUrls, visitedModules);
168
+ }
169
+ const elements = Array.from(preloadUrls).map(
170
+ (href) => this.#generateElement({
171
+ tag: "link",
172
+ attributes: { rel: "stylesheet", as: "style", href }
173
+ })
174
+ );
175
+ elements.forEach((element) => cssTagsElement.add(element));
176
+ const viteHmr = this.#getViteHmrScript(attributes);
177
+ const result = [...cssTagsElement, viteHmr].concat(tags);
178
+ return result.sort((tag) => tag.tag === "link" ? -1 : 1);
123
179
  }
124
180
  /**
125
181
  * Get a chunk from the manifest file for a given file name
@@ -184,7 +240,7 @@ var Vite = class {
184
240
  /**
185
241
  * Generate tags for the entry points
186
242
  */
187
- generateEntryPointsTags(entryPoints, attributes) {
243
+ async generateEntryPointsTags(entryPoints, attributes) {
188
244
  entryPoints = Array.isArray(entryPoints) ? entryPoints : [entryPoints];
189
245
  if (this.isViteRunning) {
190
246
  return this.#generateEntryPointsTagsForDevMode(entryPoints, attributes);
@@ -229,11 +285,12 @@ var Vite = class {
229
285
  */
230
286
  async createDevServer(options) {
231
287
  const { createServer } = await import("vite");
232
- this.#devServer = await createServer({
233
- server: { middlewareMode: true, hmr: { port: 3001 } },
288
+ this.#createServerPromise = createServer({
289
+ server: { middlewareMode: true },
234
290
  appType: "custom",
235
291
  ...options
236
292
  });
293
+ this.#devServer = await this.#createServerPromise;
237
294
  }
238
295
  /**
239
296
  * Create a runtime instance
@@ -248,6 +305,7 @@ var Vite = class {
248
305
  * Stop the Vite Dev server
249
306
  */
250
307
  async stopDevServer() {
308
+ await this.#createServerPromise;
251
309
  await this.#devServer?.close();
252
310
  }
253
311
  /**
@@ -286,4 +344,4 @@ var Vite = class {
286
344
  export {
287
345
  Vite
288
346
  };
289
- //# sourceMappingURL=chunk-ZPOSCQPO.js.map
347
+ //# sourceMappingURL=chunk-W6CJOSLQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vite.ts"],"sourcesContent":["/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { join } from 'node:path'\nimport { readFileSync } from 'node:fs'\nimport { slash } from '@poppinss/utils'\nimport type { ViteRuntime } from 'vite/runtime'\nimport type {\n InlineConfig,\n MainThreadRuntimeOptions,\n Manifest,\n ModuleNode,\n ViteDevServer,\n} from 'vite'\n\nimport { makeAttributes, uniqBy } from './utils.js'\nimport type { AdonisViteElement, SetAttributes, ViteOptions } from './types.js'\n\nconst styleFileRegex = /\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)/\n\n/**\n * Vite class exposes the APIs to generate tags and URLs for\n * assets processed using vite.\n */\nexport class Vite {\n /**\n * We cache the manifest file content in production\n * to avoid reading the file multiple times\n */\n #manifestCache?: Manifest\n #options: ViteOptions\n #devServer?: ViteDevServer\n #createServerPromise?: Promise<ViteDevServer>\n\n constructor(\n protected isViteRunning: boolean,\n options: ViteOptions\n ) {\n this.#options = options\n this.#options.assetsUrl = (this.#options.assetsUrl || '/').replace(/\\/$/, '')\n }\n\n /**\n * Reads the file contents as JSON\n */\n #readFileAsJSON(filePath: string) {\n return JSON.parse(readFileSync(filePath, 'utf-8'))\n }\n\n /**\n * Generates a JSON element with a custom toString implementation\n */\n #generateElement(element: AdonisViteElement) {\n return {\n ...element,\n toString() {\n const attributes = `${makeAttributes(element.attributes)}`\n if (element.tag === 'link') {\n return `<${element.tag} ${attributes}/>`\n }\n\n return `<${element.tag} ${attributes}>${element.children.join('\\n')}</${element.tag}>`\n },\n }\n }\n\n /**\n * Returns the script needed for the HMR working with Vite\n */\n #getViteHmrScript(attributes?: Record<string, any>) {\n return this.#generateElement({\n tag: 'script',\n attributes: {\n type: 'module',\n src: '/@vite/client',\n ...attributes,\n },\n children: [],\n })\n }\n\n /**\n * Check if the given path is a CSS path\n */\n #isCssPath(path: string) {\n return path.match(styleFileRegex) !== null\n }\n\n /**\n * If the module is a style module\n */\n #isStyleModule(mod: ModuleNode) {\n if (this.#isCssPath(mod.url) || (mod.id && /\\?vue&type=style/.test(mod.id))) {\n return true\n }\n return false\n }\n\n /**\n * Unwrap attributes from the user defined function or return\n * the attributes as it is\n */\n #unwrapAttributes(src: string, url: string, attributes?: SetAttributes) {\n if (typeof attributes === 'function') {\n return attributes({ src, url })\n }\n\n return attributes\n }\n\n /**\n * Create a style tag for the given path\n */\n #makeStyleTag(src: string, url: string, attributes?: Record<string, any>): AdonisViteElement {\n const customAttributes = this.#unwrapAttributes(src, url, this.#options?.styleAttributes)\n return this.#generateElement({\n tag: 'link',\n attributes: { rel: 'stylesheet', ...customAttributes, ...attributes, href: url },\n })\n }\n\n /**\n * Create a script tag for the given path\n */\n #makeScriptTag(src: string, url: string, attributes?: Record<string, any>): AdonisViteElement {\n const customAttributes = this.#unwrapAttributes(src, url, this.#options?.scriptAttributes)\n return this.#generateElement({\n tag: 'script',\n attributes: { type: 'module', ...customAttributes, ...attributes, src: url },\n children: [],\n })\n }\n\n /**\n * Generate an asset URL for a given asset path\n */\n #generateAssetUrl(path: string): string {\n return `${this.#options.assetsUrl}/${path}`\n }\n\n /**\n * Generate a HTML tag for the given asset\n */\n #generateTag(asset: string, attributes?: Record<string, any>): AdonisViteElement {\n let url = ''\n if (this.isViteRunning) {\n url = `/${asset}`\n } else {\n url = this.#generateAssetUrl(asset)\n }\n\n if (this.#isCssPath(asset)) {\n return this.#makeStyleTag(asset, url, attributes)\n }\n\n return this.#makeScriptTag(asset, url, attributes)\n }\n\n /**\n * Collect CSS files from the module graph recursively\n */\n #collectCss(\n mod: ModuleNode,\n styleUrls: Set<string>,\n visitedModules: Set<string>,\n importer?: ModuleNode\n ): void {\n if (!mod.url) return\n\n /**\n * Prevent visiting the same module twice\n */\n if (visitedModules.has(mod.url)) return\n visitedModules.add(mod.url)\n\n if (this.#isStyleModule(mod) && (!importer || !this.#isStyleModule(importer))) {\n if (mod.url.startsWith('/')) {\n styleUrls.add(mod.url)\n } else if (mod.url.startsWith('\\0')) {\n // virtual modules are prefixed with \\0\n styleUrls.add(`/@id/__x00__${mod.url.substring(1)}`)\n } else {\n styleUrls.add(`/@id/${mod.url}`)\n }\n }\n\n mod.importedModules.forEach((dep) => this.#collectCss(dep, styleUrls, visitedModules, mod))\n }\n\n /**\n * Generate style and script tags for the given entrypoints\n * Also adds the @vite/client script\n */\n async #generateEntryPointsTagsForDevMode(\n entryPoints: string[],\n attributes?: Record<string, any>\n ): Promise<AdonisViteElement[]> {\n const server = this.getDevServer()!\n\n const tags = entryPoints.map((entrypoint) => this.#generateTag(entrypoint, attributes))\n const jsEntrypoints = entryPoints.filter((entrypoint) => !this.#isCssPath(entrypoint))\n\n /**\n * If the module graph is empty, that means we didn't execute the entrypoint\n * yet : we just started the AdonisJS dev server.\n * So let's execute the entrypoints to populate the module graph\n */\n if (server?.moduleGraph.idToModuleMap.size === 0) {\n await Promise.allSettled(\n jsEntrypoints.map((entrypoint) => server.warmupRequest(`/${entrypoint}`))\n )\n }\n\n /**\n * We need to collect the CSS files imported by the entrypoints\n * Otherwise, we gonna have a FOUC each time we full reload the page\n */\n const preloadUrls = new Set<string>()\n const visitedModules = new Set<string>()\n const cssTagsElement = new Set<AdonisViteElement>()\n\n /**\n * Let's search for the CSS files by browsing the module graph\n * generated by Vite.\n */\n for (const entryPoint of jsEntrypoints) {\n const filePath = join(server.config.root, entryPoint)\n const entryMod = server.moduleGraph.getModuleById(slash(filePath))\n if (entryMod) this.#collectCss(entryMod, preloadUrls, visitedModules)\n }\n\n /**\n * Once we have the CSS files, generate associated tags\n * that will be injected into the HTML\n */\n const elements = Array.from(preloadUrls).map((href) =>\n this.#generateElement({\n tag: 'link',\n attributes: { rel: 'stylesheet', as: 'style', href: href },\n })\n )\n elements.forEach((element) => cssTagsElement.add(element))\n\n const viteHmr = this.#getViteHmrScript(attributes)\n const result = [...cssTagsElement, viteHmr].concat(tags)\n\n return result.sort((tag) => (tag.tag === 'link' ? -1 : 1))\n }\n\n /**\n * Get a chunk from the manifest file for a given file name\n */\n #chunk(manifest: Manifest, entrypoint: string) {\n const chunk = manifest[entrypoint]\n\n if (!chunk) {\n throw new Error(`Cannot find \"${entrypoint}\" chunk in the manifest file`)\n }\n\n return chunk\n }\n\n /**\n * Get a list of chunks for a given filename\n */\n #chunksByFile(manifest: Manifest, file: string) {\n return Object.entries(manifest)\n .filter(([, chunk]) => chunk.file === file)\n .map(([_, chunk]) => chunk)\n }\n\n /**\n * Generate preload tag for a given url\n */\n #makePreloadTagForUrl(url: string) {\n const attributes = this.#isCssPath(url)\n ? { rel: 'preload', as: 'style', href: url }\n : { rel: 'modulepreload', href: url }\n\n return this.#generateElement({ tag: 'link', attributes })\n }\n\n /**\n * Generate style and script tags for the given entrypoints\n * using the manifest file\n */\n #generateEntryPointsTagsWithManifest(\n entryPoints: string[],\n attributes?: Record<string, any>\n ): AdonisViteElement[] {\n const manifest = this.manifest()\n const tags: { path: string; tag: AdonisViteElement }[] = []\n const preloads: Array<{ path: string }> = []\n\n for (const entryPoint of entryPoints) {\n /**\n * 1. We generate tags + modulepreload for the entrypoint\n */\n const chunk = this.#chunk(manifest, entryPoint)\n preloads.push({ path: this.#generateAssetUrl(chunk.file) })\n tags.push({\n path: chunk.file,\n tag: this.#generateTag(chunk.file, { ...attributes, integrity: chunk.integrity }),\n })\n\n /**\n * 2. We go through the CSS files that are imported by the entrypoint\n * and generate tags + preload for them\n */\n for (const css of chunk.css || []) {\n preloads.push({ path: this.#generateAssetUrl(css) })\n tags.push({ path: css, tag: this.#generateTag(css) })\n }\n\n /**\n * 3. We go through every import of the entrypoint and generate preload\n */\n for (const importNode of chunk.imports || []) {\n preloads.push({ path: this.#generateAssetUrl(manifest[importNode].file) })\n\n /**\n * 4. Finally, we generate tags + preload for the CSS files imported by the import\n * of the entrypoint\n */\n for (const css of manifest[importNode].css || []) {\n const subChunk = this.#chunksByFile(manifest, css)\n\n preloads.push({ path: this.#generateAssetUrl(css) })\n tags.push({\n path: this.#generateAssetUrl(css),\n tag: this.#generateTag(css, {\n ...attributes,\n integrity: subChunk[0]?.integrity,\n }),\n })\n }\n }\n }\n\n /**\n * We sort the preload to ensure that CSS files are preloaded first\n */\n const preloadsElements = uniqBy(preloads, 'path')\n .sort((preload) => (this.#isCssPath(preload.path) ? -1 : 1))\n .map((preload) => this.#makePreloadTagForUrl(preload.path))\n\n /**\n * And finally, we return the preloads + script and link tags\n */\n return preloadsElements.concat(tags.map(({ tag }) => tag))\n }\n\n /**\n * Generate tags for the entry points\n */\n async generateEntryPointsTags(\n entryPoints: string[] | string,\n attributes?: Record<string, any>\n ): Promise<AdonisViteElement[]> {\n entryPoints = Array.isArray(entryPoints) ? entryPoints : [entryPoints]\n\n if (this.isViteRunning) {\n return this.#generateEntryPointsTagsForDevMode(entryPoints, attributes)\n }\n\n return this.#generateEntryPointsTagsWithManifest(entryPoints, attributes)\n }\n\n /**\n * Returns the explicitly configured assetsUrl\n */\n assetsUrl() {\n return this.#options.assetsUrl\n }\n\n /**\n * Returns path to a given asset file using the manifest file\n */\n assetPath(asset: string): string {\n if (this.isViteRunning) {\n return `/${asset}`\n }\n\n const chunk = this.#chunk(this.manifest(), asset)\n return this.#generateAssetUrl(chunk.file)\n }\n\n /**\n * Returns the manifest file contents\n *\n * @throws Will throw an exception when running in dev\n */\n manifest(): Manifest {\n if (this.isViteRunning) {\n throw new Error('Cannot read the manifest file when running in dev mode')\n }\n\n if (!this.#manifestCache) {\n this.#manifestCache = this.#readFileAsJSON(this.#options.manifestFile)\n }\n\n return this.#manifestCache!\n }\n\n /**\n * Create the Vite Dev Server and runtime\n *\n * We lazy load the APIs to avoid loading it in production\n * since we don't need it\n */\n async createDevServer(options?: InlineConfig) {\n const { createServer } = await import('vite')\n\n /**\n * We do not await the server creation since it will\n * slow down the boot process of AdonisJS\n */\n this.#createServerPromise = createServer({\n server: { middlewareMode: true },\n appType: 'custom',\n ...options,\n })\n\n this.#devServer = await this.#createServerPromise\n }\n\n /**\n * Create a runtime instance\n * Will not be available when running in production since\n * it needs the Vite Dev server\n */\n async createRuntime(options: MainThreadRuntimeOptions = {}): Promise<ViteRuntime> {\n const { createViteRuntime } = await import('vite')\n\n return createViteRuntime(this.#devServer!, options)\n }\n\n /**\n * Stop the Vite Dev server\n */\n async stopDevServer() {\n await this.#createServerPromise\n await this.#devServer?.close()\n }\n\n /**\n * Get the Vite Dev server instance\n * Will not be available when running in production\n */\n getDevServer() {\n return this.#devServer\n }\n\n /**\n * Returns the script needed for the HMR working with React\n */\n getReactHmrScript(attributes?: Record<string, any>): AdonisViteElement | null {\n if (!this.isViteRunning) {\n return null\n }\n\n return this.#generateElement({\n tag: 'script',\n attributes: {\n type: 'module',\n ...attributes,\n },\n children: [\n '',\n `import RefreshRuntime from '/@react-refresh'`,\n `RefreshRuntime.injectIntoGlobalHook(window)`,\n `window.$RefreshReg$ = () => {}`,\n `window.$RefreshSig$ = () => (type) => type`,\n `window.__vite_plugin_react_preamble_installed__ = true`,\n '',\n ],\n })\n }\n}\n"],"mappings":";;;;;;AASA,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAC7B,SAAS,aAAa;AAatB,IAAM,iBAAiB;AAMhB,IAAM,OAAN,MAAW;AAAA,EAUhB,YACY,eACV,SACA;AAFU;AAGV,SAAK,WAAW;AAChB,SAAK,SAAS,aAAa,KAAK,SAAS,aAAa,KAAK,QAAQ,OAAO,EAAE;AAAA,EAC9E;AAAA;AAAA;AAAA;AAAA;AAAA,EAXA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAaA,gBAAgB,UAAkB;AAChC,WAAO,KAAK,MAAM,aAAa,UAAU,OAAO,CAAC;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAiB,SAA4B;AAC3C,WAAO;AAAA,MACL,GAAG;AAAA,MACH,WAAW;AACT,cAAM,aAAa,GAAG,eAAe,QAAQ,UAAU,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@@
1
1
  import {
2
2
  Vite
3
- } from "./chunk-ZPOSCQPO.js";
3
+ } from "./chunk-W6CJOSLQ.js";
4
4
  import "./chunk-CFRBPZ4N.js";
5
5
 
6
6
  // stubs/main.ts
@@ -17,7 +17,11 @@ async function configure(command) {
17
17
  await codemods.updateRcFile((rcFile) => {
18
18
  rcFile.addProvider("@adonisjs/vite/vite_provider");
19
19
  rcFile.addMetaFile("public/**", false);
20
+ rcFile.addAssemblerHook("onBuildStarting", "@adonisjs/vite/build_hook");
20
21
  });
22
+ await codemods.registerMiddleware("server", [
23
+ { path: "@adonisjs/vite/vite_middleware", position: "after" }
24
+ ]);
21
25
  if (shouldInstallPackages === void 0) {
22
26
  shouldInstallPackages = await command.prompt.confirm('Do you want to install "vite"?');
23
27
  }
@@ -26,6 +30,16 @@ async function configure(command) {
26
30
  } else {
27
31
  await codemods.listPackagesToInstall([{ name: "vite", isDevDependency: true }]);
28
32
  }
33
+ const tsMorph = await import("ts-morph");
34
+ const project = await codemods.getTsMorphProject();
35
+ const adonisRcFile = project?.getSourceFile("adonisrc.ts");
36
+ const defineConfigCall = adonisRcFile?.getDescendantsOfKind(tsMorph.SyntaxKind.CallExpression).find((statement) => statement.getExpression().getText() === "defineConfig");
37
+ const configObject = defineConfigCall.getArguments()[0].asKindOrThrow(tsMorph.SyntaxKind.ObjectLiteralExpression);
38
+ configObject.addPropertyAssignment({
39
+ name: "assetsBundler",
40
+ initializer: "false"
41
+ });
42
+ await adonisRcFile?.save();
29
43
  }
30
44
 
31
45
  // src/define_config.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../stubs/main.ts","../configure.ts","../src/define_config.ts"],"sourcesContent":["/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { getDirname } from '@poppinss/utils'\nexport const stubsRoot = getDirname(import.meta.url)\n","/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type Configure from '@adonisjs/core/commands/configure'\n\nimport { stubsRoot } from './stubs/main.js'\n\n/**\n * Configures the package\n */\nexport async function configure(command: Configure) {\n const codemods = await command.createCodemods()\n let shouldInstallPackages: boolean | undefined = command.parsedFlags.install\n\n /**\n * Publish stubs\n */\n await codemods.makeUsingStub(stubsRoot, 'config/vite.stub', {})\n await codemods.makeUsingStub(stubsRoot, 'vite.config.stub', {})\n await codemods.makeUsingStub(stubsRoot, 'js_entrypoint.stub', {})\n\n await codemods.updateRcFile((rcFile) => {\n rcFile.addProvider('@adonisjs/vite/vite_provider')\n rcFile.addMetaFile('public/**', false)\n })\n\n /**\n * Prompt when `install` or `--no-install` flags are\n * not used\n */\n if (shouldInstallPackages === undefined) {\n shouldInstallPackages = await command.prompt.confirm('Do you want to install \"vite\"?')\n }\n\n /**\n * Install dependency or list the command to install it\n */\n if (shouldInstallPackages) {\n await codemods.installPackages([{ name: 'vite', isDevDependency: true }])\n } else {\n await codemods.listPackagesToInstall([{ name: 'vite', isDevDependency: true }])\n }\n}\n","/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { join } from 'node:path'\n\nimport type { ViteOptions } from './types.js'\n\n/**\n * Define the backend config for Vite\n */\nexport function defineConfig(config: Partial<ViteOptions>): ViteOptions {\n return {\n buildDirectory: 'public/assets',\n assetsUrl: '/assets',\n manifestFile: config.buildDirectory\n ? join(config.buildDirectory, '.vite/manifest.json')\n : 'public/assets/.vite/manifest.json',\n ...config,\n }\n}\n"],"mappings":";;;;;;AASA,SAAS,kBAAkB;AACpB,IAAM,YAAY,WAAW,YAAY,GAAG;;;ACMnD,eAAsB,UAAU,SAAoB;AAClD,QAAM,WAAW,MAAM,QAAQ,eAAe;AAC9C,MAAI,wBAA6C,QAAQ,YAAY;AAKrE,QAAM,SAAS,cAAc,WAAW,oBAAoB,CAAC,CAAC;AAC9D,QAAM,SAAS,cAAc,WAAW,oBAAoB,CAAC,CAAC;AAC9D,QAAM,SAAS,cAAc,WAAW,sBAAsB,CAAC,CAAC;AAEhE,QAAM,SAAS,aAAa,CAAC,WAAW;AACtC,WAAO,YAAY,8BAA8B;AACjD,WAAO,YAAY,aAAa,KAAK;AAAA,EACvC,CAAC;AAMD,MAAI,0BAA0B,QAAW;AACvC,4BAAwB,MAAM,QAAQ,OAAO,QAAQ,gCAAgC;AAAA,EACvF;AAKA,MAAI,uBAAuB;AACzB,UAAM,SAAS,gBAAgB,CAAC,EAAE,MAAM,QAAQ,iBAAiB,KAAK,CAAC,CAAC;AAAA,EAC1E,OAAO;AACL,UAAM,SAAS,sBAAsB,CAAC,EAAE,MAAM,QAAQ,iBAAiB,KAAK,CAAC,CAAC;AAAA,EAChF;AACF;;;ACvCA,SAAS,YAAY;AAOd,SAAS,aAAa,QAA2C;AACtE,SAAO;AAAA,IACL,gBAAgB;AAAA,IAChB,WAAW;AAAA,IACX,cAAc,OAAO,iBACjB,KAAK,OAAO,gBAAgB,qBAAqB,IACjD;AAAA,IACJ,GAAG;AAAA,EACL;AACF;","names":[]}
1
+ {"version":3,"sources":["../stubs/main.ts","../configure.ts","../src/define_config.ts"],"sourcesContent":["/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { getDirname } from '@poppinss/utils'\nexport const stubsRoot = getDirname(import.meta.url)\n","/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type Configure from '@adonisjs/core/commands/configure'\n\nimport { stubsRoot } from './stubs/main.js'\n\n/**\n * Configures the package\n */\nexport async function configure(command: Configure) {\n const codemods = await command.createCodemods()\n let shouldInstallPackages: boolean | undefined = command.parsedFlags.install\n\n /**\n * Publish stubs\n */\n await codemods.makeUsingStub(stubsRoot, 'config/vite.stub', {})\n await codemods.makeUsingStub(stubsRoot, 'vite.config.stub', {})\n await codemods.makeUsingStub(stubsRoot, 'js_entrypoint.stub', {})\n\n /**\n * Update RC file\n */\n await codemods.updateRcFile((rcFile) => {\n rcFile.addProvider('@adonisjs/vite/vite_provider')\n rcFile.addMetaFile('public/**', false)\n rcFile.addAssemblerHook('onBuildStarting', '@adonisjs/vite/build_hook')\n })\n\n /**\n * Add server middleware\n */\n await codemods.registerMiddleware('server', [\n { path: '@adonisjs/vite/vite_middleware', position: 'after' },\n ])\n\n /**\n * Prompt when `install` or `--no-install` flags are\n * not used\n */\n if (shouldInstallPackages === undefined) {\n shouldInstallPackages = await command.prompt.confirm('Do you want to install \"vite\"?')\n }\n\n /**\n * Install dependency or list the command to install it\n */\n if (shouldInstallPackages) {\n await codemods.installPackages([{ name: 'vite', isDevDependency: true }])\n } else {\n await codemods.listPackagesToInstall([{ name: 'vite', isDevDependency: true }])\n }\n\n /**\n * Add `assetsBundler: false` to the adonisrc file\n */\n const tsMorph = await import('ts-morph')\n const project = await codemods.getTsMorphProject()\n const adonisRcFile = project?.getSourceFile('adonisrc.ts')\n const defineConfigCall = adonisRcFile\n ?.getDescendantsOfKind(tsMorph.SyntaxKind.CallExpression)\n .find((statement) => statement.getExpression().getText() === 'defineConfig')\n\n const configObject = defineConfigCall!\n .getArguments()[0]\n .asKindOrThrow(tsMorph.SyntaxKind.ObjectLiteralExpression)\n\n configObject.addPropertyAssignment({\n name: 'assetsBundler',\n initializer: 'false',\n })\n\n await adonisRcFile?.save()\n}\n","/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { join } from 'node:path'\n\nimport type { ViteOptions } from './types.js'\n\n/**\n * Define the backend config for Vite\n */\nexport function defineConfig(config: Partial<ViteOptions>): ViteOptions {\n return {\n buildDirectory: 'public/assets',\n assetsUrl: '/assets',\n manifestFile: config.buildDirectory\n ? join(config.buildDirectory, '.vite/manifest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,sBAAsB;AAAA,IACjC,MAAM;AAAA,IACN,aAAa;AAAA,EACf,CAAC;AAED,QAAM,cAAc,KAAK;AAC3B;;;ACvEA,SAAS,YAAY;AAOd,SAAS,aAAa,QAA2C;AACtE,SAAO;AAAA,IACL,gBAAgB;AAAA,IAChB,WAAW;AAAA,IACX,cAAc,OAAO,iBACjB,KAAK,OAAO,gBAAgB,qBAAqB,IACjD;AAAA,IACJ,GAAG;AAAA,EACL;AACF;","names":[]}
@@ -1,10 +1,10 @@
1
+ import {
2
+ ViteMiddleware
3
+ } from "../chunk-G4LGE4JY.js";
1
4
  import {
2
5
  Vite
3
- } from "../chunk-ZPOSCQPO.js";
6
+ } from "../chunk-W6CJOSLQ.js";
4
7
  import "../chunk-CFRBPZ4N.js";
5
- import {
6
- ViteMiddleware
7
- } from "../chunk-MQRASPMO.js";
8
8
 
9
9
  // providers/vite_provider.ts
10
10
  var ViteProvider = class {
@@ -53,7 +53,7 @@ var ViteProvider = class {
53
53
  const config = this.app.config.get("vite");
54
54
  const vite = new Vite(this.#shouldRunVite, config);
55
55
  this.app.container.bind("vite", () => vite);
56
- this.app.container.bind(ViteMiddleware, () => new ViteMiddleware(vite));
56
+ this.app.container.singleton(ViteMiddleware, () => new ViteMiddleware(vite));
57
57
  }
58
58
  /**
59
59
  * - Register edge tags
@@ -64,9 +64,7 @@ var ViteProvider = class {
64
64
  if (!this.#shouldRunVite)
65
65
  return;
66
66
  const vite = await this.app.container.make("vite");
67
- const server = await this.app.container.make("server");
68
67
  await vite.createDevServer();
69
- server.use([() => import("../vite_middleware-AQXJUYMB.js")]);
70
68
  }
71
69
  /**
72
70
  * Stop Vite server when running in development or test
@@ -1 +1 @@
1
- {"version":3,"sources":["../../providers/vite_provider.ts"],"sourcesContent":["/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type { ApplicationService } from '@adonisjs/core/types'\nimport type { cspKeywords as ShieldCSPKeywords } from '@adonisjs/shield'\n\nimport { Vite } from '../src/vite.js'\nimport type { ViteOptions } from '../src/types.js'\nimport ViteMiddleware from '../src/middleware/vite_middleware.js'\n\ndeclare module '@adonisjs/core/types' {\n interface ContainerBindings {\n vite: Vite\n }\n}\n\nexport default class ViteProvider {\n #shouldRunVite: boolean\n\n constructor(protected app: ApplicationService) {\n /**\n * We should only run Vite in development and test environments\n */\n const env = this.app.getEnvironment()\n this.#shouldRunVite = (this.app.inDev || this.app.inTest) && (env === 'web' || env === 'test')\n }\n\n /**\n * Registers edge plugin when edge is installed\n */\n protected async registerEdgePlugin() {\n if (this.app.usingEdgeJS) {\n const edge = await import('edge.js')\n const vite = await this.app.container.make('vite')\n const { edgePluginVite } = await import('../src/plugins/edge.js')\n edge.default.use(edgePluginVite(vite))\n }\n }\n\n /**\n * Registers CSP keywords when @adonisjs/shield is installed\n */\n protected async registerShieldKeywords() {\n let cspKeywords: typeof ShieldCSPKeywords | null = null\n try {\n const shieldExports = await import('@adonisjs/shield')\n cspKeywords = shieldExports.cspKeywords\n } catch {}\n\n if (!cspKeywords) return\n\n const vite = await this.app.container.make('vite')\n\n /**\n * Registering the @viteUrl keyword for CSP directives.\n * Returns http URL to the dev or the CDN server, otherwise\n * an empty string\n */\n cspKeywords.register('@viteUrl', function () {\n const assetsURL = vite.assetsUrl()\n if (!assetsURL || !assetsURL.startsWith('http://') || assetsURL.startsWith('https://')) {\n return ''\n }\n\n return assetsURL\n })\n }\n\n /**\n * Register Vite bindings\n */\n register() {\n const config = this.app.config.get<ViteOptions>('vite')\n\n const vite = new Vite(this.#shouldRunVite, config)\n this.app.container.bind('vite', () => vite)\n this.app.container.bind(ViteMiddleware, () => new ViteMiddleware(vite))\n }\n\n /**\n * - Register edge tags\n * - Start Vite server when running in development or test\n */\n async boot() {\n await this.registerEdgePlugin()\n\n if (!this.#shouldRunVite) return\n\n const vite = await this.app.container.make('vite')\n const server = await this.app.container.make('server')\n\n await vite.createDevServer()\n server.use([() => import('../src/middleware/vite_middleware.js')])\n }\n\n /**\n * Stop Vite server when running in development or test\n */\n async shutdown() {\n if (!this.#shouldRunVite) return\n\n const vite = await this.app.container.make('vite')\n await vite.stopDevServer()\n }\n}\n"],"mappings":";;;;;;;;;AAsBA,IAAqB,eAArB,MAAkC;AAAA,EAGhC,YAAsB,KAAyB;AAAzB;AAIpB,UAAM,MAAM,KAAK,IAAI,eAAe;AACpC,SAAK,kBAAkB,KAAK,IAAI,SAAS,KAAK,IAAI,YAAY,QAAQ,SAAS,QAAQ;AAAA,EACzF;AAAA,EARA;AAAA;AAAA;AAAA;AAAA,EAaA,MAAgB,qBAAqB;AACnC,QAAI,KAAK,IAAI,aAAa;AACxB,YAAM,OAAO,MAAM,OAAO,SAAS;AACnC,YAAM,OAAO,MAAM,KAAK,IAAI,UAAU,KAAK,MAAM;AACjD,YAAM,EAAE,eAAe,IAAI,MAAM,OAAO,wBAAwB;AAChE,WAAK,QAAQ,IAAI,eAAe,IAAI,CAAC;AAAA,IACvC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAgB,yBAAyB;AACvC,QAAI,cAA+C;AACnD,QAAI;AACF,YAAM,gBAAgB,MAAM,OAAO,kBAAkB;AACrD,oBAAc,cAAc;AAAA,IAC9B,QAAQ;AAAA,IAAC;AAET,QAAI,CAAC;AAAa;AAElB,UAAM,OAAO,MAAM,KAAK,IAAI,UAAU,KAAK,MAAM;AAOjD,gBAAY,SAAS,YAAY,WAAY;AAC3C,YAAM,YAAY,KAAK,UAAU;AACjC,UAAI,CAAC,aAAa,CAAC,UAAU,WAAW,SAAS,KAAK,UAAU,WAAW,UAAU,GAAG;AACtF,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,WAAW;AACT,UAAM,SAAS,KAAK,IAAI,OAAO,IAAiB,MAAM;AAEtD,UAAM,OAAO,IAAI,KAAK,KAAK,gBAAgB,MAAM;AACjD,SAAK,IAAI,UAAU,KAAK,QAAQ,MAAM,IAAI;AAC1C,SAAK,IAAI,UAAU,KAAK,gBAAgB,MAAM,IAAI,eAAe,IAAI,CAAC;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO;AACX,UAAM,KAAK,mBAAmB;AAE9B,QAAI,CAAC,KAAK;AAAgB;AAE1B,UAAM,OAAO,MAAM,KAAK,IAAI,UAAU,KAAK,MAAM;AACjD,UAAM,SAAS,MAAM,KAAK,IAAI,UAAU,KAAK,QAAQ;AAErD,UAAM,KAAK,gBAAgB;AAC3B,WAAO,IAAI,CAAC,MAAM,OAAO,gCAAsC,CAAC,CAAC;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW;AACf,QAAI,CAAC,KAAK;AAAgB;AAE1B,UAAM,OAAO,MAAM,KAAK,IAAI,UAAU,KAAK,MAAM;AACjD,UAAM,KAAK,cAAc;AAAA,EAC3B;AACF;","names":[]}
1
+ {"version":3,"sources":["../../providers/vite_provider.ts"],"sourcesContent":["/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type { ApplicationService } from '@adonisjs/core/types'\nimport type { cspKeywords as ShieldCSPKeywords } from '@adonisjs/shield'\n\nimport { Vite } from '../src/vite.js'\nimport type { ViteOptions } from '../src/types.js'\nimport ViteMiddleware from '../src/vite_middleware.js'\n\ndeclare module '@adonisjs/core/types' {\n interface ContainerBindings {\n vite: Vite\n }\n}\n\nexport default class ViteProvider {\n #shouldRunVite: boolean\n\n constructor(protected app: ApplicationService) {\n /**\n * We should only run Vite in development and test environments\n */\n const env = this.app.getEnvironment()\n this.#shouldRunVite = (this.app.inDev || this.app.inTest) && (env === 'web' || env === 'test')\n }\n\n /**\n * Registers edge plugin when edge is installed\n */\n protected async registerEdgePlugin() {\n if (this.app.usingEdgeJS) {\n const edge = await import('edge.js')\n const vite = await this.app.container.make('vite')\n const { edgePluginVite } = await import('../src/plugins/edge.js')\n edge.default.use(edgePluginVite(vite))\n }\n }\n\n /**\n * Registers CSP keywords when @adonisjs/shield is installed\n */\n protected async registerShieldKeywords() {\n let cspKeywords: typeof ShieldCSPKeywords | null = null\n try {\n const shieldExports = await import('@adonisjs/shield')\n cspKeywords = shieldExports.cspKeywords\n } catch {}\n\n if (!cspKeywords) return\n\n const vite = await this.app.container.make('vite')\n\n /**\n * Registering the @viteUrl keyword for CSP directives.\n * Returns http URL to the dev or the CDN server, otherwise\n * an empty string\n */\n cspKeywords.register('@viteUrl', function () {\n const assetsURL = vite.assetsUrl()\n if (!assetsURL || !assetsURL.startsWith('http://') || assetsURL.startsWith('https://')) {\n return ''\n }\n\n return assetsURL\n })\n }\n\n /**\n * Register Vite bindings\n */\n register() {\n const config = this.app.config.get<ViteOptions>('vite')\n\n const vite = new Vite(this.#shouldRunVite, config)\n this.app.container.bind('vite', () => vite)\n this.app.container.singleton(ViteMiddleware, () => new ViteMiddleware(vite))\n }\n\n /**\n * - Register edge tags\n * - Start Vite server when running in development or test\n */\n async boot() {\n await this.registerEdgePlugin()\n\n if (!this.#shouldRunVite) return\n\n const vite = await this.app.container.make('vite')\n await vite.createDevServer()\n }\n\n /**\n * Stop Vite server when running in development or test\n */\n async shutdown() {\n if (!this.#shouldRunVite) return\n\n const vite = await this.app.container.make('vite')\n await vite.stopDevServer()\n }\n}\n"],"mappings":";;;;;;;;;AAsBA,IAAqB,eAArB,MAAkC;AAAA,EAGhC,YAAsB,KAAyB;AAAzB;AAIpB,UAAM,MAAM,KAAK,IAAI,eAAe;AACpC,SAAK,kBAAkB,KAAK,IAAI,SAAS,KAAK,IAAI,YAAY,QAAQ,SAAS,QAAQ;AAAA,EACzF;AAAA,EARA;AAAA;AAAA;AAAA;AAAA,EAaA,MAAgB,qBAAqB;AACnC,QAAI,KAAK,IAAI,aAAa;AACxB,YAAM,OAAO,MAAM,OAAO,SAAS;AACnC,YAAM,OAAO,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C3B;AACF;","names":[]}
@@ -1,12 +1,5 @@
1
- import type { AliasOptions, ConfigEnv, Plugin, UserConfig } from 'vite';
1
+ import type { ConfigEnv, Plugin, UserConfig } from 'vite';
2
2
  import type { PluginFullOptions } from './types.js';
3
- /**
4
- * Resolve the `config.resolve.alias` value
5
- *
6
- * Basically we are merging the user defined alias with the
7
- * default alias.
8
- */
9
- export declare function resolveAlias(config: UserConfig): AliasOptions;
10
3
  /**
11
4
  * Resolve the `config.base` value
12
5
  */
@@ -7,16 +7,6 @@ import PluginRestart from "vite-plugin-restart";
7
7
 
8
8
  // src/client/config.ts
9
9
  import { join } from "node:path";
10
- function resolveAlias(config2) {
11
- const defaultAlias = { "@/": `/resources/js/` };
12
- if (Array.isArray(config2.resolve?.alias)) {
13
- return [
14
- ...config2.resolve?.alias ?? [],
15
- ...Object.entries(defaultAlias).map(([find, replacement]) => ({ find, replacement }))
16
- ];
17
- }
18
- return { ...defaultAlias, ...config2.resolve?.alias };
19
- }
20
10
  function resolveBase(config2, options, command) {
21
11
  if (config2.base)
22
12
  return config2.base;
@@ -28,8 +18,13 @@ function resolveBase(config2, options, command) {
28
18
  function configHook(options, userConfig, { command }) {
29
19
  const config2 = {
30
20
  publicDir: userConfig.publicDir ?? false,
31
- resolve: { alias: resolveAlias(userConfig) },
32
21
  base: resolveBase(userConfig, options, command),
22
+ /**
23
+ * Disable the vite dev server cors handling. Otherwise, it will
24
+ * override the cors settings defined by @adonisjs/cors
25
+ * https://github.com/adonisjs/vite/issues/13
26
+ */
27
+ server: { cors: userConfig.server?.cors ?? false },
33
28
  build: {
34
29
  assetsDir: "",
35
30
  emptyOutDir: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/main.ts","../../../src/client/config.ts"],"sourcesContent":["/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\n/// <reference types=\"@vavite/multibuild\" />\n\nimport { PluginOption } from 'vite'\nimport PluginRestart from 'vite-plugin-restart'\n\nimport { config } from './config.js'\nimport type { PluginOptions } from './types.js'\n\ndeclare module 'vite' {\n interface ManifestChunk {\n integrity: string\n }\n}\n\n/**\n * Vite plugin for AdonisJS\n */\nexport default function adonisjs(options: PluginOptions): PluginOption[] {\n const fullOptions = Object.assign(\n {\n assetsUrl: '/assets',\n buildDirectory: 'public/assets',\n reload: ['./resources/views/**/*.edge'],\n },\n options\n )\n\n return [PluginRestart({ reload: fullOptions.reload }), config(fullOptions)]\n}\n","/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { join } from 'node:path'\nimport type { AliasOptions, ConfigEnv, Plugin, UserConfig } from 'vite'\n\nimport { addTrailingSlash } from '../utils.js'\nimport type { PluginFullOptions } from './types.js'\n\n/**\n * Resolve the `config.resolve.alias` value\n *\n * Basically we are merging the user defined alias with the\n * default alias.\n */\nexport function resolveAlias(config: UserConfig): AliasOptions {\n const defaultAlias = { '@/': `/resources/js/` }\n\n if (Array.isArray(config.resolve?.alias)) {\n return [\n ...(config.resolve?.alias ?? []),\n ...Object.entries(defaultAlias).map(([find, replacement]) => ({ find, replacement })),\n ]\n }\n\n return { ...defaultAlias, ...config.resolve?.alias }\n}\n\n/**\n * Resolve the `config.base` value\n */\nexport function resolveBase(\n config: UserConfig,\n options: PluginFullOptions,\n command: 'build' | 'serve'\n): string {\n if (config.base) return config.base\n if (command === 'build') {\n return addTrailingSlash(options.assetsUrl)\n }\n\n return '/'\n}\n\n/**\n * Vite config hook\n */\nexport function configHook(\n options: PluginFullOptions,\n userConfig: UserConfig,\n { command }: ConfigEnv\n): UserConfig {\n const config: UserConfig = {\n publicDir: userConfig.publicDir ?? false,\n resolve: { alias: resolveAlias(userConfig) },\n base: resolveBase(userConfig, options, command),\n\n build: {\n assetsDir: '',\n emptyOutDir: true,\n manifest: userConfig.build?.manifest ?? true,\n outDir: userConfig.build?.outDir ?? options.buildDirectory,\n assetsInlineLimit: userConfig.build?.assetsInlineLimit ?? 0,\n\n rollupOptions: {\n input: options.entrypoints.map((entrypoint) => join(userConfig.root || '', entrypoint)),\n },\n },\n }\n\n return config\n}\n\n/**\n * Update the user vite config to match the Adonis requirements\n */\nexport const config = (options: PluginFullOptions): Plugin => {\n return {\n name: 'vite-plugin-adonis:config',\n enforce: 'post',\n config: configHook.bind(null, options),\n }\n}\n"],"mappings":";;;;;AAYA,OAAO,mBAAmB;;;ACH1B,SAAS,YAAY;AAYd,SAAS,aAAaA,SAAkC;AAC7D,QAAM,eAAe,EAAE,MAAM,iBAAiB;AAE9C,MAAI,MAAM,QAAQA,QAAO,SAAS,KAAK,GAAG;AACxC,WAAO;AAAA,MACL,GAAIA,QAAO,SAAS,SAAS,CAAC;AAAA,MAC9B,GAAG,OAAO,QAAQ,YAAY,EAAE,IAAI,CAAC,CAAC,MAAM,WAAW,OAAO,EAAE,MAAM,YAAY,EAAE;AAAA,IACtF;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,cAAc,GAAGA,QAAO,SAAS,MAAM;AACrD;AAKO,SAAS,YACdA,SACA,SACA,SACQ;AACR,MAAIA,QAAO;AAAM,WAAOA,QAAO;AAC/B,MAAI,YAAY,SAAS;AACvB,WAAO,iBAAiB,QAAQ,SAAS;AAAA,EAC3C;AAEA,SAAO;AACT;AAKO,SAAS,WACd,SACA,YACA,EAAE,QAAQ,GACE;AACZ,QAAMA,UAAqB;AAAA,IACzB,WAAW,WAAW,aAAa;AAAA,IACnC,SAAS,EAAE,OAAO,aAAa,UAAU,EAAE;AAAA,IAC3C,MAAM,YAAY,YAAY,SAAS,OAAO;AAAA,IAE9C,OAAO;AAAA,MACL,WAAW;AAAA,MACX,aAAa;AAAA,MACb,UAAU,WAAW,OAAO,YAAY;AAAA,MACxC,QAAQ,WAAW,OAAO,UAAU,QAAQ;AAAA,MAC5C,mBAAmB,WAAW,OAAO,qBAAqB;AAAA,MAE1D,eAAe;AAAA,QACb,OAAO,QAAQ,YAAY,IAAI,CAAC,eAAe,KAAK,WAAW,QAAQ,IAAI,UAAU,CAAC;AAAA,MACxF;AAAA,IACF;AAAA,EACF;AAEA,SAAOA;AACT;AAKO,IAAM,SAAS,CAAC,YAAuC;AAC5D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ,WAAW,KAAK,MAAM,OAAO;AAAA,EACvC;AACF;;;AD9De,SAAR,SAA0B,SAAwC;AACvE,QAAM,cAAc,OAAO;AAAA,IACzB;AAAA,MACE,WAAW;AAAA,MACX,gBAAgB;AAAA,MAChB,QAAQ,CAAC,6BAA6B;AAAA,IACxC;AAAA,IACA;AAAA,EACF;AAEA,SAAO,CAAC,cAAc,EAAE,QAAQ,YAAY,OAAO,CAAC,GAAG,OAAO,WAAW,CAAC;AAC5E;","names":["config"]}
1
+ {"version":3,"sources":["../../../src/client/main.ts","../../../src/client/config.ts"],"sourcesContent":["/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\n/// <reference types=\"@vavite/multibuild\" />\n\nimport { PluginOption } from 'vite'\nimport PluginRestart from 'vite-plugin-restart'\n\nimport { config } from './config.js'\nimport type { PluginOptions } from './types.js'\n\ndeclare module 'vite' {\n interface ManifestChunk {\n integrity: string\n }\n}\n\n/**\n * Vite plugin for AdonisJS\n */\nexport default function adonisjs(options: PluginOptions): PluginOption[] {\n const fullOptions = Object.assign(\n {\n assetsUrl: '/assets',\n buildDirectory: 'public/assets',\n reload: ['./resources/views/**/*.edge'],\n },\n options\n )\n\n return [PluginRestart({ reload: fullOptions.reload }), config(fullOptions)]\n}\n","/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { join } from 'node:path'\nimport type { ConfigEnv, Plugin, UserConfig } from 'vite'\n\nimport { addTrailingSlash } from '../utils.js'\nimport type { PluginFullOptions } from './types.js'\n\n/**\n * Resolve the `config.base` value\n */\nexport function resolveBase(\n config: UserConfig,\n options: PluginFullOptions,\n command: 'build' | 'serve'\n): string {\n if (config.base) return config.base\n if (command === 'build') {\n return addTrailingSlash(options.assetsUrl)\n }\n\n return '/'\n}\n\n/**\n * Vite config hook\n */\nexport function configHook(\n options: PluginFullOptions,\n userConfig: UserConfig,\n { command }: ConfigEnv\n): UserConfig {\n const config: UserConfig = {\n publicDir: userConfig.publicDir ?? false,\n base: resolveBase(userConfig, options, command),\n\n /**\n * Disable the vite dev server cors handling. Otherwise, it will\n * override the cors settings defined by @adonisjs/cors\n * https://github.com/adonisjs/vite/issues/13\n */\n server: { cors: userConfig.server?.cors ?? false },\n\n build: {\n assetsDir: '',\n emptyOutDir: true,\n manifest: userConfig.build?.manifest ?? true,\n outDir: userConfig.build?.outDir ?? options.buildDirectory,\n assetsInlineLimit: userConfig.build?.assetsInlineLimit ?? 0,\n\n rollupOptions: {\n input: options.entrypoints.map((entrypoint) => join(userConfig.root || '', entrypoint)),\n },\n },\n }\n\n return config\n}\n\n/**\n * Update the user vite config to match the Adonis requirements\n */\nexport const config = (options: PluginFullOptions): Plugin => {\n return {\n name: 'vite-plugin-adonis:config',\n enforce: 'post',\n config: configHook.bind(null, options),\n }\n}\n"],"mappings":";;;;;AAYA,OAAO,mBAAmB;;;ACH1B,SAAS,YAAY;AASd,SAAS,YACdA,SACA,SACA,SACQ;AACR,MAAIA,QAAO;AAAM,WAAOA,QAAO;AAC/B,MAAI,YAAY,SAAS;AACvB,WAAO,iBAAiB,QAAQ,SAAS;AAAA,EAC3C;AAEA,SAAO;AACT;AAKO,SAAS,WACd,SACA,YACA,EAAE,QAAQ,GACE;AACZ,QAAMA,UAAqB;AAAA,IACzB,WAAW,WAAW,aAAa;AAAA,IACnC,MAAM,YAAY,YAAY,SAAS,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO9C,QAAQ,EAAE,MAAM,WAAW,QAAQ,QAAQ,MAAM;AAAA,IAEjD,OAAO;AAAA,MACL,WAAW;AAAA,MACX,aAAa;AAAA,MACb,UAAU,WAAW,OAAO,YAAY;AAAA,MACxC,QAAQ,WAAW,OAAO,UAAU,QAAQ;AAAA,MAC5C,mBAAmB,WAAW,OAAO,qBAAqB;AAAA,MAE1D,eAAe;AAAA,QACb,OAAO,QAAQ,YAAY,IAAI,CAAC,eAAe,KAAK,WAAW,QAAQ,IAAI,UAAU,CAAC;AAAA,MACxF;AAAA,IACF;AAAA,EACF;AAEA,SAAOA;AACT;AAKO,IAAM,SAAS,CAAC,YAAuC;AAC5D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ,WAAW,KAAK,MAAM,OAAO;AAAA,EACvC;AACF;;;ADjDe,SAAR,SAA0B,SAAwC;AACvE,QAAM,cAAc,OAAO;AAAA,IACzB;AAAA,MACE,WAAW;AAAA,MACX,gBAAgB;AAAA,MAChB,QAAQ,CAAC,6BAA6B;AAAA,IACxC;AAAA,IACA;AAAA,EACF;AAEA,SAAO,CAAC,cAAc,EAAE,QAAQ,YAAY,OAAO,CAAC,GAAG,OAAO,WAAW,CAAC;AAC5E;","names":["config"]}
@@ -54,7 +54,7 @@ var edgePluginVite = (vite) => {
54
54
  const entrypoints = parser.utils.stringify(parsed);
55
55
  const methodCall = parsed.type === "SequenceExpression" ? `generateEntryPointsTags${entrypoints}` : `generateEntryPointsTags(${entrypoints})`;
56
56
  buffer.outputExpression(
57
- `state.vite.${methodCall}.join('\\n')`,
57
+ `(await state.vite.${methodCall}).join('\\n')`,
58
58
  token.filename,
59
59
  token.loc.start.line,
60
60
  false
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/plugins/edge.ts"],"sourcesContent":["/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type { Edge } from 'edge.js'\nimport { EdgeError } from 'edge-error'\nimport type { PluginFn } from 'edge.js/types'\n\nimport type { Vite } from '../vite.js'\n\n/**\n * The edge plugin for vite to share vite service with edge\n * and register custom tags\n */\nexport const edgePluginVite: (vite: Vite) => PluginFn<undefined> = (vite) => {\n const edgeVite = (edge: Edge) => {\n edge.global('vite', vite)\n edge.global('asset', vite.assetPath.bind(vite))\n\n edge.registerTag({\n tagName: 'viteReactRefresh',\n seekable: true,\n block: false,\n compile(parser, buffer, token) {\n let attributes = ''\n if (token.properties.jsArg.trim()) {\n /**\n * Converting a single argument to a SequenceExpression so that we\n * work around the following edge cases.\n *\n * - If someone passes an object literal to the tag, ie { nonce: 'foo' }\n * it will be parsed as a LabeledStatement and not an object.\n * - If we wrap the object literal inside parenthesis, ie ({nonce: 'foo'})\n * then we will end up messing other expressions like a variable reference\n * , or a member expression and so on.\n * - So the best bet is to convert user supplied argument to a sequence expression\n * and hence ignore it during stringification.\n */\n const jsArg = `a,${token.properties.jsArg}`\n\n const parsed = parser.utils.transformAst(\n parser.utils.generateAST(jsArg, token.loc, token.filename),\n token.filename,\n parser\n )\n attributes = parser.utils.stringify(parsed.expressions[1])\n }\n\n /**\n * Get HMR script\n */\n buffer.writeExpression(\n `const __vite_hmr_script = state.vite.getReactHmrScript(${attributes})`,\n token.filename,\n token.loc.start.line\n )\n\n /**\n * Check if the script exists (only in hot mode)\n */\n buffer.writeStatement('if(__vite_hmr_script) {', token.filename, token.loc.start.line)\n\n /**\n * Write output\n */\n buffer.outputExpression(\n `__vite_hmr_script.toString()`,\n token.filename,\n token.loc.start.line,\n false\n )\n\n /**\n * Close if block\n */\n buffer.writeStatement('}', token.filename, token.loc.start.line)\n },\n })\n\n edge.registerTag({\n tagName: 'vite',\n seekable: true,\n block: false,\n compile(parser, buffer, token) {\n /**\n * Ensure an argument is defined\n */\n if (!token.properties.jsArg.trim()) {\n throw new EdgeError('Missing entrypoint name', 'E_RUNTIME_EXCEPTION', {\n filename: token.filename,\n line: token.loc.start.line,\n col: token.loc.start.col,\n })\n }\n\n const parsed = parser.utils.transformAst(\n parser.utils.generateAST(token.properties.jsArg, token.loc, token.filename),\n token.filename,\n parser\n )\n\n const entrypoints = parser.utils.stringify(parsed)\n const methodCall =\n parsed.type === 'SequenceExpression'\n ? `generateEntryPointsTags${entrypoints}`\n : `generateEntryPointsTags(${entrypoints})`\n\n buffer.outputExpression(\n `state.vite.${methodCall}.join('\\\\n')`,\n token.filename,\n token.loc.start.line,\n false\n )\n },\n })\n }\n\n return edgeVite\n}\n"],"mappings":";AAUA,SAAS,iBAAiB;AASnB,IAAM,iBAAsD,CAAC,SAAS;AAC3E,QAAM,WAAW,CAAC,SAAe;AAC/B,SAAK,OAAO,QAAQ,IAAI;AACxB,SAAK,OAAO,SAAS,KAAK,UAAU,KAAK,IAAI,CAAC;AAE9C,SAAK,YAAY;AAAA,MACf,SAAS;AAAA,MACT,UAAU;AAAA,MACV,OAAO;AAAA,MACP,QAAQ,QAAQ,QAAQ,OAAO;AAC7B,YAAI,aAAa;AACjB,YAAI,MAAM,WAAW,MAAM,KAAK,GAAG;AAajC,gBAAM,QAAQ,KAAK,MAAM,WAAW,KAAK;AAEzC,gBAAM,SAAS,OAAO,MAAM;AAAA,YAC1B,OAAO,MAAM,YAAY,OAAO,MAAM,KAAK,MAAM,QAAQ;AAAA,YACzD,MAAM;AAAA,YACN;AAAA,UACF;AACA,uBAAa,OAAO,MAAM,UAAU,OAAO,YAAY,CAAC,CAAC;AAAA,QAC3D;AAKA,eAAO;AAAA,UACL,0DAA0D,UAAU;AAAA,UACpE,MAAM;AAAA,UACN,MAAM,IAAI,MAAM;AAAA,QAClB;AAKA,eAAO,eAAe,2BAA2B,MAAM,UAAU,MAAM,IAAI,MAAM,IAAI;AAKrF,eAAO;AAAA,UACL;AAAA,UACA,MAAM;AAAA,UACN,MAAM,IAAI,MAAM;AAAA,UAChB;AAAA,QACF;AAKA,eAAO,eAAe,KAAK,MAAM,UAAU,MAAM,IAAI,MAAM,IAAI;AAAA,MACjE;AAAA,IACF,CAAC;AAED,SAAK,YAAY;AAAA,MACf,SAAS;AAAA,MACT,UAAU;AAAA,MACV,OAAO;AAAA,MACP,QAAQ,QAAQ,QAAQ,OAAO;AAI7B,YAAI,CAAC,MAAM,WAAW,MAAM,KAAK,GAAG;AAClC,gBAAM,IAAI,UAAU,2BAA2B,uBAAuB;AAAA,YACpE,UAAU,MAAM;AAAA,YAChB,MAAM,MAAM,IAAI,MAAM;AAAA,YACtB,KAAK,MAAM,IAAI,MAAM;AAAA,UACvB,CAAC;AAAA,QACH;AAEA,cAAM,SAAS,OAAO,MAAM;AAAA,UAC1B,OAAO,MAAM,YAAY,MAAM,WAAW,OAAO,MAAM,KAAK,MAAM,QAAQ;AAAA,UAC1E,MAAM;AAAA,UACN;AAAA,QACF;AAEA,cAAM,cAAc,OAAO,MAAM,UAAU,MAAM;AACjD,cAAM,aACJ,OAAO,SAAS,uBACZ,0BAA0B,WAAW,KACrC,2BAA2B,WAAW;AAE5C,eAAO;AAAA,UACL,cAAc,UAAU;AAAA,UACxB,MAAM;AAAA,UACN,MAAM,IAAI,MAAM;AAAA,UAChB;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/plugins/edge.ts"],"sourcesContent":["/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type { Edge } from 'edge.js'\nimport { EdgeError } from 'edge-error'\nimport type { PluginFn } from 'edge.js/types'\n\nimport type { Vite } from '../vite.js'\n\n/**\n * The edge plugin for vite to share vite service with edge\n * and register custom tags\n */\nexport const edgePluginVite: (vite: Vite) => PluginFn<undefined> = (vite) => {\n const edgeVite = (edge: Edge) => {\n edge.global('vite', vite)\n edge.global('asset', vite.assetPath.bind(vite))\n\n edge.registerTag({\n tagName: 'viteReactRefresh',\n seekable: true,\n block: false,\n compile(parser, buffer, token) {\n let attributes = ''\n if (token.properties.jsArg.trim()) {\n /**\n * Converting a single argument to a SequenceExpression so that we\n * work around the following edge cases.\n *\n * - If someone passes an object literal to the tag, ie { nonce: 'foo' }\n * it will be parsed as a LabeledStatement and not an object.\n * - If we wrap the object literal inside parenthesis, ie ({nonce: 'foo'})\n * then we will end up messing other expressions like a variable reference\n * , or a member expression and so on.\n * - So the best bet is to convert user supplied argument to a sequence expression\n * and hence ignore it during stringification.\n */\n const jsArg = `a,${token.properties.jsArg}`\n\n const parsed = parser.utils.transformAst(\n parser.utils.generateAST(jsArg, token.loc, token.filename),\n token.filename,\n parser\n )\n attributes = parser.utils.stringify(parsed.expressions[1])\n }\n\n /**\n * Get HMR script\n */\n buffer.writeExpression(\n `const __vite_hmr_script = state.vite.getReactHmrScript(${attributes})`,\n token.filename,\n token.loc.start.line\n )\n\n /**\n * Check if the script exists (only in hot mode)\n */\n buffer.writeStatement('if(__vite_hmr_script) {', token.filename, token.loc.start.line)\n\n /**\n * Write output\n */\n buffer.outputExpression(\n `__vite_hmr_script.toString()`,\n token.filename,\n token.loc.start.line,\n false\n )\n\n /**\n * Close if block\n */\n buffer.writeStatement('}', token.filename, token.loc.start.line)\n },\n })\n\n edge.registerTag({\n tagName: 'vite',\n seekable: true,\n block: false,\n compile(parser, buffer, token) {\n /**\n * Ensure an argument is defined\n */\n if (!token.properties.jsArg.trim()) {\n throw new EdgeError('Missing entrypoint name', 'E_RUNTIME_EXCEPTION', {\n filename: token.filename,\n line: token.loc.start.line,\n col: token.loc.start.col,\n })\n }\n\n const parsed = parser.utils.transformAst(\n parser.utils.generateAST(token.properties.jsArg, token.loc, token.filename),\n token.filename,\n parser\n )\n\n const entrypoints = parser.utils.stringify(parsed)\n const methodCall =\n parsed.type === 'SequenceExpression'\n ? `generateEntryPointsTags${entrypoints}`\n : `generateEntryPointsTags(${entrypoints})`\n\n buffer.outputExpression(\n `(await state.vite.${methodCall}).join('\\\\n')`,\n token.filename,\n token.loc.start.line,\n false\n )\n },\n })\n }\n\n return edg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I,MAAM;AAAA,UACvB,CAAC;AAAA,QACH;AAEA,cAAM,SAAS,OAAO,MAAM;AAAA,UAC1B,OAAO,MAAM,YAAY,MAAM,WAAW,OAAO,MAAM,KAAK,MAAM,QAAQ;AAAA,UAC1E,MAAM;AAAA,UACN;AAAA,QACF;AAEA,cAAM,cAAc,OAAO,MAAM,UAAU,MAAM;AACjD,cAAM,aACJ,OAAO,SAAS,uBACZ,0BAA0B,WAAW,KACrC,2BAA2B,WAAW;AAE5C,eAAO;AAAA,UACL,qBAAqB,UAAU;AAAA,UAC/B,MAAM;AAAA,UACN,MAAM,IAAI,MAAM;AAAA,UAChB;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
@@ -12,7 +12,7 @@ export declare class Vite {
12
12
  /**
13
13
  * Generate tags for the entry points
14
14
  */
15
- generateEntryPointsTags(entryPoints: string[] | string, attributes?: Record<string, any>): AdonisViteElement[];
15
+ generateEntryPointsTags(entryPoints: string[] | string, attributes?: Record<string, any>): Promise<AdonisViteElement[]>;
16
16
  /**
17
17
  * Returns the explicitly configured assetsUrl
18
18
  */
@@ -1,6 +1,6 @@
1
1
  import type { HttpContext } from '@adonisjs/core/http';
2
2
  import type { NextFn } from '@adonisjs/core/types/http';
3
- import type { Vite } from '../vite.js';
3
+ import type { Vite } from './vite.js';
4
4
  /**
5
5
  * Since Vite dev server is integrated within the AdonisJS process, this
6
6
  * middleware is used to proxy the requests to it.
@@ -13,5 +13,5 @@ export default class ViteMiddleware {
13
13
  #private;
14
14
  protected vite: Vite;
15
15
  constructor(vite: Vite);
16
- handle({ request, response }: HttpContext, next: NextFn): Promise<unknown>;
16
+ handle({ request, response }: HttpContext, next: NextFn): Promise<any>;
17
17
  }
@@ -0,0 +1,7 @@
1
+ import {
2
+ ViteMiddleware
3
+ } from "../chunk-G4LGE4JY.js";
4
+ export {
5
+ ViteMiddleware as default
6
+ };
7
+ //# sourceMappingURL=vite_middleware.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adonisjs/vite",
3
3
  "description": "Vite plugin for AdonisJS",
4
- "version": "3.0.0-8",
4
+ "version": "3.0.0",
5
5
  "engines": {
6
6
  "node": ">=20.6.0"
7
7
  },
@@ -17,6 +17,7 @@
17
17
  ".": "./build/index.js",
18
18
  "./vite_provider": "./build/providers/vite_provider.js",
19
19
  "./plugins/edge": "./build/src/plugins/edge.js",
20
+ "./vite_middleware": "./build/src/vite_middleware.js",
20
21
  "./build_hook": "./build/src/hooks/build_hook.js",
21
22
  "./services/main": "./build/services/vite.js",
22
23
  "./client": "./build/src/client/main.js",
@@ -24,7 +25,7 @@
24
25
  },
25
26
  "scripts": {
26
27
  "clean": "del-cli build",
27
- "copy:templates": "copyfiles \"stubs/**/*.stub\" build",
28
+ "copy:templates": "copyfiles --up 1 \"stubs/**/*.stub\" build",
28
29
  "typecheck": "tsc --noEmit",
29
30
  "lint": "eslint . --ext=.ts",
30
31
  "format": "prettier --write .",
@@ -34,38 +35,41 @@
34
35
  "prebuild": "npm run lint && npm run clean",
35
36
  "build": "tsup-node && tsc --emitDeclarationOnly --declaration",
36
37
  "postbuild": "npm run copy:templates",
37
- "release": "np",
38
+ "release": "release-it",
38
39
  "version": "npm run build",
39
40
  "prepublishOnly": "npm run build"
40
41
  },
41
42
  "devDependencies": {
42
- "@adonisjs/assembler": "^7.2.2",
43
- "@adonisjs/core": "6.3.1",
44
- "@adonisjs/eslint-config": "^1.2.1",
45
- "@adonisjs/prettier-config": "^1.2.1",
46
- "@adonisjs/session": "^7.1.1",
43
+ "@adonisjs/assembler": "^7.7.0",
44
+ "@adonisjs/core": "6.9.1",
45
+ "@adonisjs/eslint-config": "^1.3.0",
46
+ "@adonisjs/prettier-config": "^1.3.0",
47
+ "@adonisjs/session": "^7.4.0",
47
48
  "@adonisjs/shield": "^8.1.1",
48
- "@adonisjs/tsconfig": "^1.2.1",
49
- "@japa/assert": "2.1.0",
50
- "@japa/file-system": "^2.2.0",
51
- "@japa/runner": "3.1.1",
52
- "@japa/snapshot": "^2.0.4",
53
- "@swc/core": "^1.4.2",
54
- "@types/node": "^20.11.20",
49
+ "@adonisjs/tsconfig": "^1.3.0",
50
+ "@japa/assert": "3.0.0",
51
+ "@japa/file-system": "^2.3.0",
52
+ "@japa/runner": "3.1.4",
53
+ "@japa/snapshot": "^2.0.5",
54
+ "@swc/core": "^1.5.24",
55
+ "@types/node": "^20.13.0",
56
+ "@types/supertest": "^6.0.2",
55
57
  "c8": "^9.1.0",
56
58
  "copyfiles": "^2.4.1",
57
59
  "del-cli": "^5.1.0",
58
- "edge.js": "^6.0.1",
60
+ "edge.js": "^6.0.2",
59
61
  "eslint": "^8.57.0",
60
- "np": "^10.0.0",
61
- "prettier": "^3.2.5",
62
+ "prettier": "^3.3.0",
63
+ "release-it": "^17.3.0",
64
+ "supertest": "^6.3.4",
65
+ "ts-morph": "^22.0.0",
62
66
  "ts-node": "^10.9.2",
63
67
  "tsup": "^8.0.2",
64
- "typescript": "~5.3.3",
65
- "vite": "^5.1.4"
68
+ "typescript": "~5.4.5",
69
+ "vite": "^5.2.12"
66
70
  },
67
71
  "dependencies": {
68
- "@poppinss/utils": "^6.7.2",
72
+ "@poppinss/utils": "^6.7.3",
69
73
  "@vavite/multibuild": "^4.1.1",
70
74
  "edge-error": "^4.0.1",
71
75
  "vite-plugin-restart": "^0.4.0"
@@ -106,12 +110,6 @@
106
110
  "access": "public",
107
111
  "tag": "next"
108
112
  },
109
- "np": {
110
- "message": "chore(release): %s",
111
- "tag": "next",
112
- "branch": "next",
113
- "anyBranch": false
114
- },
115
113
  "c8": {
116
114
  "reporter": [
117
115
  "text",
@@ -126,6 +124,7 @@
126
124
  "entry": [
127
125
  "./src/hooks/build_hook.ts",
128
126
  "./providers/vite_provider.ts",
127
+ "./src/vite_middleware.ts",
129
128
  "./src/plugins/edge.ts",
130
129
  "./src/client/main.ts",
131
130
  "./services/vite.ts",
@@ -138,5 +137,17 @@
138
137
  "dts": false,
139
138
  "sourcemap": true,
140
139
  "target": "esnext"
140
+ },
141
+ "release-it": {
142
+ "git": {
143
+ "commitMessage": "chore(release): ${version}",
144
+ "tagAnnotation": "v${version}",
145
+ "tagName": "v${version}"
146
+ },
147
+ "github": {
148
+ "release": true,
149
+ "releaseName": "v${version}",
150
+ "web": true
151
+ }
141
152
  }
142
153
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/middleware/vite_middleware.ts"],"sourcesContent":["/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type { ViteDevServer } from 'vite'\nimport type { HttpContext } from '@adonisjs/core/http'\nimport type { NextFn } from '@adonisjs/core/types/http'\n\nimport type { Vite } from '../vite.js'\n\n/**\n * Since Vite dev server is integrated within the AdonisJS process, this\n * middleware is used to proxy the requests to it.\n *\n * Some of the requests are directly handled by the Vite dev server,\n * like the one for the assets, while others are passed down to the\n * AdonisJS server.\n */\nexport default class ViteMiddleware {\n #devServer: ViteDevServer\n\n constructor(protected vite: Vite) {\n this.#devServer = this.vite.getDevServer()!\n }\n\n async handle({ request, response }: HttpContext, next: NextFn) {\n return await new Promise((resolve) => {\n this.#devServer.middlewares.handle(request.request, response.response, () => {\n return resolve(next())\n })\n })\n }\n}\n"],"mappings":";AAuBA,IAAqB,iBAArB,MAAoC;AAAA,EAGlC,YAAsB,MAAY;AAAZ;AACpB,SAAK,aAAa,KAAK,KAAK,aAAa;AAAA,EAC3C;AAAA,EAJA;AAAA,EAMA,MAAM,OAAO,EAAE,SAAS,SAAS,GAAgB,MAAc;AAC7D,WAAO,MAAM,IAAI,QAAQ,CAAC,YAAY;AACpC,WAAK,WAAW,YAAY,OAAO,QAAQ,SAAS,SAAS,UAAU,MAAM;AAC3E,eAAO,QAAQ,KAAK,CAAC;AAAA,MACvB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/vite.ts"],"sourcesContent":["/*\n * @adonisjs/vite\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { readFileSync } from 'node:fs'\nimport type { ViteRuntime } from 'vite/runtime'\nimport type { InlineConfig, MainThreadRuntimeOptions, Manifest, ViteDevServer } from 'vite'\n\nimport { makeAttributes, uniqBy } from './utils.js'\nimport type { AdonisViteElement, SetAttributes, ViteOptions } from './types.js'\n\n/**\n * Vite class exposes the APIs to generate tags and URLs for\n * assets processed using vite.\n */\nexport class Vite {\n /**\n * We cache the manifest file content in production\n * to avoid reading the file multiple times\n */\n #manifestCache?: Manifest\n #options: ViteOptions\n #devServer?: ViteDevServer\n\n constructor(\n protected isViteRunning: boolean,\n options: ViteOptions\n ) {\n this.#options = options\n this.#options.assetsUrl = (this.#options.assetsUrl || '/').replace(/\\/$/, '')\n }\n\n /**\n * Reads the file contents as JSON\n */\n #readFileAsJSON(filePath: string) {\n return JSON.parse(readFileSync(filePath, 'utf-8'))\n }\n\n /**\n * Generates a JSON element with a custom toString implementation\n */\n #generateElement(element: AdonisViteElement) {\n return {\n ...element,\n toString() {\n const attributes = `${makeAttributes(element.attributes)}`\n if (element.tag === 'link') {\n return `<${element.tag} ${attributes}/>`\n }\n\n return `<${element.tag} ${attributes}>${element.children.join('\\n')}</${element.tag}>`\n },\n }\n }\n\n /**\n * Returns the script needed for the HMR working with Vite\n */\n #getViteHmrScript(attributes?: Record<string, any>): AdonisViteElement | null {\n return this.#generateElement({\n tag: 'script',\n attributes: {\n type: 'module',\n src: '/@vite/client',\n ...attributes,\n },\n children: [],\n })\n }\n\n /**\n * Check if the given path is a CSS path\n */\n #isCssPath(path: string) {\n return path.match(/\\.(css|less|sass|scss|styl|stylus|pcss|postcss)$/) !== null\n }\n\n /**\n * Unwrap attributes from the user defined function or return\n * the attributes as it is\n */\n #unwrapAttributes(src: string, url: string, attributes?: SetAttributes) {\n if (typeof attributes === 'function') {\n return attributes({ src, url })\n }\n\n return attributes\n }\n\n /**\n * Create a style tag for the given path\n */\n #makeStyleTag(src: string, url: string, attributes?: Record<string, any>): AdonisViteElement {\n const customAttributes = this.#unwrapAttributes(src, url, this.#options?.styleAttributes)\n return this.#generateElement({\n tag: 'link',\n attributes: { rel: 'stylesheet', ...customAttributes, ...attributes, href: url },\n })\n }\n\n /**\n * Create a script tag for the given path\n */\n #makeScriptTag(src: string, url: string, attributes?: Record<string, any>): AdonisViteElement {\n const customAttributes = this.#unwrapAttributes(src, url, this.#options?.scriptAttributes)\n return this.#generateElement({\n tag: 'script',\n attributes: { type: 'module', ...customAttributes, ...attributes, src: url },\n children: [],\n })\n }\n\n /**\n * Generate an asset URL for a given asset path\n */\n #generateAssetUrl(path: string): string {\n return `${this.#options.assetsUrl}/${path}`\n }\n\n /**\n * Generate a HTML tag for the given asset\n */\n #generateTag(asset: string, attributes?: Record<string, any>): AdonisViteElement {\n let url = ''\n if (this.isViteRunning) {\n url = `/${asset}`\n } else {\n url = this.#generateAssetUrl(asset)\n }\n\n if (this.#isCssPath(asset)) {\n return this.#makeStyleTag(asset, url, attributes)\n }\n\n return this.#makeScriptTag(asset, url, attributes)\n }\n\n /**\n * Generate style and script tags for the given entrypoints\n * Also adds the @vite/client script\n */\n #generateEntryPointsTagsForDevMode(\n entryPoints: string[],\n attributes?: Record<string, any>\n ): AdonisViteElement[] {\n const viteHmr = this.#getViteHmrScript(attributes)\n const tags = entryPoints.map((entrypoint) => this.#generateTag(entrypoint, attributes))\n\n const result = viteHmr ? [viteHmr].concat(tags) : tags\n\n return result\n }\n\n /**\n * Get a chunk from the manifest file for a given file name\n */\n #chunk(manifest: Manifest, entrypoint: string) {\n const chunk = manifest[entrypoint]\n\n if (!chunk) {\n throw new Error(`Cannot find \"${entrypoint}\" chunk in the manifest file`)\n }\n\n return chunk\n }\n\n /**\n * Get a list of chunks for a given filename\n */\n #chunksByFile(manifest: Manifest, file: string) {\n return Object.entries(manifest)\n .filter(([, chunk]) => chunk.file === file)\n .map(([_, chunk]) => chunk)\n }\n\n /**\n * Generate preload tag for a given url\n */\n #makePreloadTagForUrl(url: string) {\n const attributes = this.#isCssPath(url)\n ? { rel: 'preload', as: 'style', href: url }\n : { rel: 'modulepreload', href: url }\n\n return this.#generateElement({ tag: 'link', attributes })\n }\n\n /**\n * Generate style and script tags for the given entrypoints\n * using the manifest file\n */\n #generateEntryPointsTagsWithManifest(\n entryPoints: string[],\n attributes?: Record<string, any>\n ): AdonisViteElement[] {\n const manifest = this.manifest()\n const tags: { path: string; tag: AdonisViteElement }[] = []\n const preloads: Array<{ path: string }> = []\n\n for (const entryPoint of entryPoints) {\n /**\n * 1. We generate tags + modulepreload for the entrypoint\n */\n const chunk = this.#chunk(manifest, entryPoint)\n preloads.push({ path: this.#generateAssetUrl(chunk.file) })\n tags.push({\n path: chunk.file,\n tag: this.#generateTag(chunk.file, { ...attributes, integrity: chunk.integrity }),\n })\n\n /**\n * 2. We go through the CSS files that are imported by the entrypoint\n * and generate tags + preload for them\n */\n for (const css of chunk.css || []) {\n preloads.push({ path: this.#generateAssetUrl(css) })\n tags.push({ path: css, tag: this.#generateTag(css) })\n }\n\n /**\n * 3. We go through every import of the entrypoint and generate preload\n */\n for (const importNode of chunk.imports || []) {\n preloads.push({ path: this.#generateAssetUrl(manifest[importNode].file) })\n\n /**\n * 4. Finally, we generate tags + preload for the CSS files imported by the import\n * of the entrypoint\n */\n for (const css of manifest[importNode].css || []) {\n const subChunk = this.#chunksByFile(manifest, css)\n\n preloads.push({ path: this.#generateAssetUrl(css) })\n tags.push({\n path: this.#generateAssetUrl(css),\n tag: this.#generateTag(css, {\n ...attributes,\n integrity: subChunk[0]?.integrity,\n }),\n })\n }\n }\n }\n\n /**\n * We sort the preload to ensure that CSS files are preloaded first\n */\n const preloadsElements = uniqBy(preloads, 'path')\n .sort((preload) => (this.#isCssPath(preload.path) ? -1 : 1))\n .map((preload) => this.#makePreloadTagForUrl(preload.path))\n\n /**\n * And finally, we return the preloads + script and link tags\n */\n return preloadsElements.concat(tags.map(({ tag }) => tag))\n }\n\n /**\n * Generate tags for the entry points\n */\n generateEntryPointsTags(\n entryPoints: string[] | string,\n attributes?: Record<string, any>\n ): AdonisViteElement[] {\n entryPoints = Array.isArray(entryPoints) ? entryPoints : [entryPoints]\n\n if (this.isViteRunning) {\n return this.#generateEntryPointsTagsForDevMode(entryPoints, attributes)\n }\n\n return this.#generateEntryPointsTagsWithManifest(entryPoints, attributes)\n }\n\n /**\n * Returns the explicitly configured assetsUrl\n */\n assetsUrl() {\n return this.#options.assetsUrl\n }\n\n /**\n * Returns path to a given asset file using the manifest file\n */\n assetPath(asset: string): string {\n if (this.isViteRunning) {\n return `/${asset}`\n }\n\n const chunk = this.#chunk(this.manifest(), asset)\n return this.#generateAssetUrl(chunk.file)\n }\n\n /**\n * Returns the manifest file contents\n *\n * @throws Will throw an exception when running in dev\n */\n manifest(): Manifest {\n if (this.isViteRunning) {\n throw new Error('Cannot read the manifest file when running in dev mode')\n }\n\n if (!this.#manifestCache) {\n this.#manifestCache = this.#readFileAsJSON(this.#options.manifestFile)\n }\n\n return this.#manifestCache!\n }\n\n /**\n * Create the Vite Dev Server and runtime\n *\n * We lazy load the APIs to avoid loading it in production\n * since we don't need it\n */\n async createDevServer(options?: InlineConfig) {\n const { createServer } = await import('vite')\n\n this.#devServer = await createServer({\n server: { middlewareMode: true, hmr: { port: 3001 } },\n appType: 'custom',\n ...options,\n })\n }\n\n /**\n * Create a runtime instance\n * Will not be available when running in production since\n * it needs the Vite Dev server\n */\n async createRuntime(options: MainThreadRuntimeOptions = {}): Promise<ViteRuntime> {\n const { createViteRuntime } = await import('vite')\n\n return createViteRuntime(this.#devServer!, options)\n }\n\n /**\n * Stop the Vite Dev server\n */\n async stopDevServer() {\n await this.#devServer?.close()\n }\n\n /**\n * Get the Vite Dev server instance\n * Will not be available when running in production\n */\n getDevServer() {\n return this.#devServer\n }\n\n /**\n * Returns the script needed for the HMR working with React\n */\n getReactHmrScript(attributes?: Record<string, any>): AdonisViteElement | null {\n if (!this.isViteRunning) {\n return null\n }\n\n return this.#generateElement({\n tag: 'script',\n attributes: {\n type: 'module',\n ...attributes,\n },\n children: [\n '',\n `import RefreshRuntime from '/@react-refresh'`,\n `RefreshRuntime.injectIntoGlobalHook(window)`,\n `window.$RefreshReg$ = () => {}`,\n `window.$RefreshSig$ = () => (type) => type`,\n `window.__vite_plugin_react_preamble_installed__ = true`,\n '',\n ],\n })\n }\n}\n"],"mappings":";;;;;;AASA,SAAS,oBAAoB;AAWtB,IAAM,OAAN,MAAW;AAAA,EAShB,YACY,eACV,SACA;AAFU;AAGV,SAAK,WAAW;AAChB,SAAK,SAAS,aAAa,KAAK,SAAS,aAAa,KAAK,QAAQ,OAAO,EAAE;AAAA,EAC9E;AAAA;AAAA;AAAA;AAAA;AAAA,EAVA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAaA,gBAAgB,UAAkB;AAChC,WAAO,KAAK,MAAM,aAAa,UAAU,OAAO,CAAC;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAiB,SAA4B;AAC3C,WAAO;AAAA,MACL,GAAG;AAAA,MACH,WAAW;AACT,cAAM,aAAa,GAAG,eAAe,QAAQ,UAAU,CAAC;AACxD,YAAI,QAAQ,QAAQ,QAAQ;AAC1B,iBAAO,IAAI,QAAQ,GAAG,IAAI,UAAU;AAAA,QACtC;AAEA,eAAO,IAAI,QAAQ,GAAG,IAAI,UAAU,IAAI,QAAQ,SAAS,KAAK,IAAI,CAAC,KAAK,QAAQ,GAAG;AAAA,MACrF;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAkB,YAA4D;AAC5E,WAAO,KAAK,iBAAiB;AAAA,MAC3B,KAAK;AAAA,MACL,YAAY;AAAA,QACV,MAAM;AAAA,QACN,KAAK;AAAA,QACL,GAAG;AAAA,MACL;AAAA,MACA,UAAU,CA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AAA;AAAA;AAAA,EAKA,kBAAkB,YAA4D;AAC5E,QAAI,CAAC,KAAK,eAAe;AACvB,aAAO;AAAA,IACT;AAEA,WAAO,KAAK,iBAAiB;AAAA,MAC3B,KAAK;AAAA,MACL,YAAY;AAAA,QACV,MAAM;AAAA,QACN,GAAG;AAAA,MACL;AAAA,MACA,UAAU;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -1,7 +0,0 @@
1
- import {
2
- ViteMiddleware
3
- } from "./chunk-MQRASPMO.js";
4
- export {
5
- ViteMiddleware as default
6
- };
7
- //# sourceMappingURL=vite_middleware-AQXJUYMB.js.map
File without changes