@adonisjs/vite 2.0.2 → 3.0.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.
Files changed (38) hide show
  1. package/LICENSE.md +1 -1
  2. package/build/index.d.ts +2 -2
  3. package/build/index.js +2 -2
  4. package/build/providers/vite_provider.d.ts +4 -10
  5. package/build/providers/vite_provider.js +22 -53
  6. package/build/services/vite.d.ts +1 -1
  7. package/build/src/client/config.d.ts +13 -2
  8. package/build/src/client/config.js +36 -42
  9. package/build/src/client/main.d.ts +1 -1
  10. package/build/src/client/main.js +4 -6
  11. package/build/src/client/types.d.ts +12 -21
  12. package/build/src/define_config.d.ts +5 -0
  13. package/build/src/{backend/define_config.js → define_config.js} +1 -2
  14. package/build/src/hooks/build_hook.d.ts +8 -0
  15. package/build/src/hooks/build_hook.js +25 -0
  16. package/build/src/middlewares/vite_middleware.d.ts +17 -0
  17. package/build/src/middlewares/vite_middleware.js +31 -0
  18. package/build/src/{backend/plugins → plugins}/edge.js +2 -4
  19. package/build/src/{backend/types.d.ts → types.d.ts} +6 -22
  20. package/build/src/{backend/utils.d.ts → utils.d.ts} +4 -0
  21. package/build/src/{backend/utils.js → utils.js} +6 -0
  22. package/build/src/{backend/vite.d.ts → vite.d.ts} +27 -9
  23. package/build/src/{backend/vite.js → vite.js} +106 -104
  24. package/build/stubs/vite.config.stub +1 -1
  25. package/package.json +36 -56
  26. package/build/src/backend/debug.d.ts +0 -3
  27. package/build/src/backend/debug.js +0 -10
  28. package/build/src/backend/define_config.d.ts +0 -5
  29. package/build/src/client/config_resolver.d.ts +0 -20
  30. package/build/src/client/config_resolver.js +0 -46
  31. package/build/src/client/helpers/inertia.d.ts +0 -4
  32. package/build/src/client/helpers/inertia.js +0 -22
  33. package/build/src/client/hot_file.d.ts +0 -14
  34. package/build/src/client/hot_file.js +0 -49
  35. package/build/src/client/utils.d.ts +0 -11
  36. package/build/src/client/utils.js +0 -44
  37. /package/build/src/{backend/plugins → plugins}/edge.d.ts +0 -0
  38. /package/build/src/{backend/types.js → types.js} +0 -0
@@ -6,33 +6,26 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
- import { existsSync, readFileSync } from 'node:fs';
10
- import debug from './debug.js';
9
+ import { readFileSync } from 'node:fs';
11
10
  import { makeAttributes, uniqBy } from './utils.js';
12
11
  /**
13
12
  * Vite class exposes the APIs to generate tags and URLs for
14
13
  * assets processed using vite.
15
14
  */
16
15
  export class Vite {
16
+ inDev;
17
17
  /**
18
18
  * We cache the manifest file content in production
19
19
  * to avoid reading the file multiple times
20
20
  */
21
- #manifestCache = null;
22
- /**
23
- * Configuration options
24
- */
21
+ #manifestCache;
25
22
  #options;
26
- constructor(options) {
23
+ #runtime;
24
+ #devServer;
25
+ constructor(inDev, options) {
26
+ this.inDev = inDev;
27
27
  this.#options = options;
28
28
  this.#options.assetsUrl = (this.#options.assetsUrl || '/').replace(/\/$/, '');
29
- debug('vite config %O', this.#options);
30
- }
31
- /**
32
- * Checks if the application is running in hot mode
33
- */
34
- #isRunningHot() {
35
- return existsSync(this.#options.hotFile);
36
29
  }
37
30
  /**
38
31
  * Reads the file contents as JSON
@@ -41,16 +34,39 @@ export class Vite {
41
34
  return JSON.parse(readFileSync(filePath, 'utf-8'));
42
35
  }
43
36
  /**
44
- * Returns the parsed hot file content
37
+ * Generates a JSON element with a custom toString implementation
45
38
  */
46
- #readHotFile() {
47
- return this.#readFileAsJSON(this.#options.hotFile);
39
+ #generateElement(element) {
40
+ return {
41
+ ...element,
42
+ toString() {
43
+ const attributes = `${makeAttributes(element.attributes)}`;
44
+ if (element.tag === 'link') {
45
+ return `<${element.tag} ${attributes}/>`;
46
+ }
47
+ return `<${element.tag} ${attributes}>${element.children.join('\n')}</${element.tag}>`;
48
+ },
49
+ };
48
50
  }
49
51
  /**
50
- * Get the path to an asset when running in hot mode
52
+ * Returns the script needed for the HMR working with Vite
51
53
  */
52
- #hotAsset(asset) {
53
- return this.#readHotFile().url + '/' + asset;
54
+ #getViteHmrScript(attributes) {
55
+ return this.#generateElement({
56
+ tag: 'script',
57
+ attributes: {
58
+ type: 'module',
59
+ src: '/@vite/client',
60
+ ...attributes,
61
+ },
62
+ children: [],
63
+ });
64
+ }
65
+ /**
66
+ * Check if the given path is a CSS path
67
+ */
68
+ #isCssPath(path) {
69
+ return path.match(/\.(css|less|sass|scss|styl|stylus|pcss|postcss)$/) !== null;
54
70
  }
55
71
  /**
56
72
  * Unwrap attributes from the user defined function or return
@@ -63,24 +79,24 @@ export class Vite {
63
79
  return attributes;
64
80
  }
65
81
  /**
66
- * Create a script tag for the given path
82
+ * Create a style tag for the given path
67
83
  */
68
- #makeScriptTag(src, url, attributes) {
69
- const customAttributes = this.#unwrapAttributes(src, url, this.#options.scriptAttributes);
84
+ #makeStyleTag(src, url, attributes) {
85
+ const customAttributes = this.#unwrapAttributes(src, url, this.#options?.styleAttributes);
70
86
  return this.#generateElement({
71
- tag: 'script',
72
- attributes: { type: 'module', ...customAttributes, ...attributes, src: url },
73
- children: [],
87
+ tag: 'link',
88
+ attributes: { rel: 'stylesheet', ...customAttributes, ...attributes, href: url },
74
89
  });
75
90
  }
76
91
  /**
77
- * Create a style tag for the given path
92
+ * Create a script tag for the given path
78
93
  */
79
- #makeStyleTag(src, url, attributes) {
80
- const customAttributes = this.#unwrapAttributes(src, url, this.#options.styleAttributes);
94
+ #makeScriptTag(src, url, attributes) {
95
+ const customAttributes = this.#unwrapAttributes(src, url, this.#options?.scriptAttributes);
81
96
  return this.#generateElement({
82
- tag: 'link',
83
- attributes: { rel: 'stylesheet', ...customAttributes, ...attributes, href: url },
97
+ tag: 'script',
98
+ attributes: { type: 'module', ...customAttributes, ...attributes, src: url },
99
+ children: [],
84
100
  });
85
101
  }
86
102
  /**
@@ -88,8 +104,8 @@ export class Vite {
88
104
  */
89
105
  #generateTag(asset, attributes) {
90
106
  let url = '';
91
- if (this.#isRunningHot()) {
92
- url = this.#hotAsset(asset);
107
+ if (this.inDev) {
108
+ url = `/${asset}`;
93
109
  }
94
110
  else {
95
111
  url = `${this.#options.assetsUrl}/${asset}`;
@@ -99,35 +115,6 @@ export class Vite {
99
115
  }
100
116
  return this.#makeScriptTag(asset, url, attributes);
101
117
  }
102
- /**
103
- * Generates a JSON element with a custom toString implementation
104
- */
105
- #generateElement(element) {
106
- return {
107
- ...element,
108
- toString() {
109
- const attributes = `${makeAttributes(element.attributes)}`;
110
- if (element.tag === 'link') {
111
- return `<${element.tag} ${attributes}/>`;
112
- }
113
- return `<${element.tag} ${attributes}>${element.children.join('\n')}</${element.tag}>`;
114
- },
115
- };
116
- }
117
- /**
118
- * Returns the script needed for the HMR working with Vite
119
- */
120
- #getViteHmrScript(attributes) {
121
- return this.#generateElement({
122
- tag: 'script',
123
- attributes: {
124
- type: 'module',
125
- src: this.#hotAsset('@vite/client'),
126
- ...attributes,
127
- },
128
- children: [],
129
- });
130
- }
131
118
  /**
132
119
  * Generate style and script tags for the given entrypoints
133
120
  * Also adds the @vite/client script
@@ -135,7 +122,18 @@ export class Vite {
135
122
  #generateEntryPointsTagsForHotMode(entryPoints, attributes) {
136
123
  const viteHmr = this.#getViteHmrScript(attributes);
137
124
  const tags = entryPoints.map((entrypoint) => this.#generateTag(entrypoint, attributes));
138
- return viteHmr ? [viteHmr].concat(tags) : tags;
125
+ const result = viteHmr ? [viteHmr].concat(tags) : tags;
126
+ return result;
127
+ }
128
+ /**
129
+ * Get a chunk from the manifest file for a given file name
130
+ */
131
+ #chunk(manifest, fileName) {
132
+ const chunk = manifest[fileName];
133
+ if (!chunk) {
134
+ throw new Error(`Cannot find "${fileName}" chunk in the manifest file`);
135
+ }
136
+ return chunk;
139
137
  }
140
138
  /**
141
139
  * Generate style and script tags for the given entrypoints
@@ -151,69 +149,39 @@ export class Vite {
151
149
  tag: this.#generateTag(chunk.file, { ...attributes, integrity: chunk.integrity }),
152
150
  });
153
151
  for (const css of chunk.css || []) {
154
- tags.push({
155
- path: css,
156
- tag: this.#generateTag(css),
157
- });
152
+ tags.push({ path: css, tag: this.#generateTag(css) });
158
153
  }
159
154
  }
160
155
  return uniqBy(tags, 'path')
161
156
  .sort((a) => (a.path.endsWith('.css') ? -1 : 1))
162
157
  .map((tag) => tag.tag);
163
158
  }
164
- /**
165
- * Get a chunk from the manifest file for a given file name
166
- */
167
- #chunk(manifest, fileName) {
168
- const chunk = manifest[fileName];
169
- if (!chunk) {
170
- throw new Error(`Cannot find "${fileName}" chunk in the manifest file`);
171
- }
172
- return chunk;
173
- }
174
- /**
175
- * Check if the given path is a CSS path
176
- */
177
- #isCssPath(path) {
178
- return path.match(/\.(css|less|sass|scss|styl|stylus|pcss|postcss)$/) !== null;
179
- }
180
159
  /**
181
160
  * Generate tags for the entry points
182
161
  */
183
162
  generateEntryPointsTags(entryPoints, attributes) {
184
163
  entryPoints = Array.isArray(entryPoints) ? entryPoints : [entryPoints];
185
- if (this.#isRunningHot()) {
164
+ if (this.inDev) {
186
165
  return this.#generateEntryPointsTagsForHotMode(entryPoints, attributes);
187
166
  }
188
167
  return this.#generateEntryPointsTagsWithManifest(entryPoints, attributes);
189
168
  }
190
- /**
191
- * Returns the dev server URL when running in hot
192
- * mode. Otherwise an empty string
193
- */
194
- devUrl() {
195
- if (this.#isRunningHot()) {
196
- return this.#readHotFile().url;
197
- }
198
- return '';
199
- }
200
169
  /**
201
170
  * Returns the dev server URL when running in hot
202
171
  * mode, otherwise returns the explicitly configured
203
172
  * "assets" URL
204
173
  */
205
174
  assetsUrl() {
206
- if (this.#isRunningHot()) {
207
- return this.#readHotFile().url;
208
- }
175
+ if (this.inDev)
176
+ return this.#devServer.config.server.host;
209
177
  return this.#options.assetsUrl;
210
178
  }
211
179
  /**
212
180
  * Returns path to a given asset file
213
181
  */
214
182
  assetPath(asset) {
215
- if (this.#isRunningHot()) {
216
- return this.#hotAsset(asset);
183
+ if (this.inDev) {
184
+ return `/${asset}`;
217
185
  }
218
186
  const chunk = this.#chunk(this.manifest(), asset);
219
187
  return `${this.#options.assetsUrl}/${chunk.file}`;
@@ -221,22 +189,56 @@ export class Vite {
221
189
  /**
222
190
  * Returns the manifest file contents
223
191
  *
224
- * @throws Will throw an exception when running in hot mode
192
+ * @throws Will throw an exception when running in dev
225
193
  */
226
194
  manifest() {
227
- if (this.#isRunningHot()) {
228
- throw new Error('Cannot read the manifest file when running in hot mode');
195
+ if (this.inDev) {
196
+ throw new Error('Cannot read the manifest file when running in dev mode');
229
197
  }
230
198
  if (!this.#manifestCache) {
231
199
  this.#manifestCache = this.#readFileAsJSON(this.#options.manifestFile);
232
200
  }
233
201
  return this.#manifestCache;
234
202
  }
203
+ /**
204
+ * Create the Vite Dev Server and runtime
205
+ *
206
+ * We lazy load the APIs to avoid loading it in production
207
+ * since we don't need it
208
+ */
209
+ async createDevServer() {
210
+ const { createViteRuntime, createServer } = await import('vite');
211
+ this.#devServer = await createServer({
212
+ server: { middlewareMode: true, hmr: { port: 3001 } },
213
+ appType: 'custom',
214
+ });
215
+ this.#runtime = await createViteRuntime(this.#devServer);
216
+ }
217
+ /**
218
+ * Stop the Vite Dev server
219
+ */
220
+ async stopDevServer() {
221
+ await this.#devServer?.close();
222
+ }
223
+ /**
224
+ * Get the Vite Dev server instance
225
+ * Will not be available when running in production
226
+ */
227
+ getDevServer() {
228
+ return this.#devServer;
229
+ }
230
+ /**
231
+ * Get the Vite runtime instance
232
+ * Will not be available when running in production
233
+ */
234
+ getRuntime() {
235
+ return this.#runtime;
236
+ }
235
237
  /**
236
238
  * Returns the script needed for the HMR working with React
237
239
  */
238
240
  getReactHmrScript(attributes) {
239
- if (!this.#isRunningHot()) {
241
+ if (!this.inDev) {
240
242
  return null;
241
243
  }
242
244
  return this.#generateElement({
@@ -247,7 +249,7 @@ export class Vite {
247
249
  },
248
250
  children: [
249
251
  '',
250
- `import RefreshRuntime from '${this.#hotAsset('@react-refresh')}'`,
252
+ `import RefreshRuntime from '/@react-refresh'`,
251
253
  `RefreshRuntime.injectIntoGlobalHook(window)`,
252
254
  `window.$RefreshReg$ = () => {}`,
253
255
  `window.$RefreshSig$ = () => (type) => type`,
@@ -1,5 +1,5 @@
1
1
  {{{
2
- exports({ to: app.makePath('vite.config.js') })
2
+ exports({ to: app.makePath('vite.config.ts') })
3
3
  }}}
4
4
  import { defineConfig } from 'vite'
5
5
  import adonisjs from '@adonisjs/vite/client'
package/package.json CHANGED
@@ -1,29 +1,29 @@
1
1
  {
2
2
  "name": "@adonisjs/vite",
3
- "description": "Vite plugin for Adonis.js",
4
- "version": "2.0.2",
3
+ "description": "Vite plugin for AdonisJS",
4
+ "version": "3.0.0-0",
5
5
  "engines": {
6
- "node": ">=18.16.0"
6
+ "node": ">=20.6.0"
7
7
  },
8
8
  "main": "build/index.js",
9
9
  "type": "module",
10
10
  "files": [
11
+ "build/providers",
12
+ "build/services",
13
+ "build/src",
14
+ "build/stubs",
11
15
  "build/configure.js",
12
16
  "build/configure.d.ts",
13
17
  "build/index.js",
14
- "build/index.d.ts",
15
- "build/stubs",
16
- "build/src",
17
- "build/services",
18
- "build/providers"
18
+ "build/index.d.ts"
19
19
  ],
20
20
  "exports": {
21
21
  ".": "./build/index.js",
22
- "./services/main": "./build/services/vite.js",
23
22
  "./vite_provider": "./build/providers/vite_provider.js",
23
+ "./services/main": "./build/services/vite.js",
24
+ "./types": "./build/src/types.js",
24
25
  "./client": "./build/src/client/main.js",
25
- "./plugins/edge": "./build/backend/plugins/edge.js",
26
- "./types": "./build/src/backend/types.js"
26
+ "./build_hook": "./build/src/build_hook.js"
27
27
  },
28
28
  "scripts": {
29
29
  "clean": "del-cli build",
@@ -34,58 +34,50 @@
34
34
  "quick:test": "node --enable-source-maps --loader=ts-node/esm bin/test.ts",
35
35
  "pretest": "npm run lint",
36
36
  "test": "c8 npm run quick:test",
37
- "precompile": "npm run lint && npm run clean ",
38
- "compile": "tsc",
39
- "postcompile": "npm run copy:templates",
40
- "build": "npm run compile",
37
+ "prebuild": "npm run lint && npm run clean",
38
+ "build": "tsc",
39
+ "postbuild": "npm run copy:templates",
41
40
  "release": "np",
42
41
  "version": "npm run build",
43
42
  "prepublishOnly": "npm run build"
44
43
  },
45
44
  "devDependencies": {
46
- "@adonisjs/assembler": "^7.0.0",
47
- "@adonisjs/core": "^6.2.0",
45
+ "@adonisjs/application": "8.1.0",
46
+ "@adonisjs/assembler": "^7.2.1",
47
+ "@adonisjs/core": "6.3.0",
48
48
  "@adonisjs/eslint-config": "^1.2.1",
49
49
  "@adonisjs/prettier-config": "^1.2.1",
50
- "@adonisjs/session": "^7.0.0",
51
- "@adonisjs/shield": "^8.0.0",
50
+ "@adonisjs/shield": "^8.1.1",
52
51
  "@adonisjs/tsconfig": "^1.2.1",
53
- "@commitlint/cli": "^18.4.4",
54
- "@commitlint/config-conventional": "^18.4.4",
55
- "@japa/assert": "^2.1.0",
56
- "@japa/expect-type": "^2.0.1",
57
- "@japa/file-system": "^2.1.1",
58
- "@japa/runner": "^3.1.1",
59
- "@swc/core": "^1.3.102",
60
- "@types/node": "^20.10.7",
61
- "c8": "^9.0.0",
52
+ "@japa/assert": "2.1.0",
53
+ "@japa/file-system": "^2.2.0",
54
+ "@japa/runner": "3.1.1",
55
+ "@swc/core": "^1.4.2",
56
+ "@types/node": "^20.11.20",
57
+ "c8": "^9.1.0",
62
58
  "copyfiles": "^2.4.1",
63
59
  "del-cli": "^5.1.0",
64
60
  "edge.js": "^6.0.1",
65
- "eslint": "^8.56.0",
66
- "husky": "^8.0.3",
61
+ "eslint": "^8.57.0",
67
62
  "np": "^9.2.0",
68
- "prettier": "^3.1.1",
69
- "rollup": "^4.9.4",
63
+ "prettier": "^3.2.5",
70
64
  "ts-node": "^10.9.2",
71
- "typescript": "^5.3.3",
72
- "vite": "^5.0.11"
65
+ "typescript": "~5.3.3",
66
+ "vite": "^5.1.4"
73
67
  },
74
68
  "dependencies": {
75
- "defu": "^6.1.4",
69
+ "@poppinss/utils": "^6.7.2",
70
+ "@vavite/multibuild": "^4.1.1",
76
71
  "edge-error": "^4.0.1",
77
72
  "vite-plugin-restart": "^0.4.0"
78
73
  },
79
74
  "peerDependencies": {
80
- "@adonisjs/core": "^6.2.0",
81
- "@adonisjs/shield": "^8.0.0",
75
+ "@adonisjs/core": "^6.3.0",
76
+ "@adonisjs/shield": "^8.1.1",
82
77
  "edge.js": "^6.0.1",
83
- "vite": "^5.0.11"
78
+ "vite": "^5.1.4"
84
79
  },
85
80
  "peerDependenciesMeta": {
86
- "vite": {
87
- "optional": true
88
- },
89
81
  "edge.js": {
90
82
  "optional": true
91
83
  },
@@ -107,27 +99,18 @@
107
99
  "vite",
108
100
  "adonisjs"
109
101
  ],
110
- "contributors": [
111
- "virk",
112
- "adonisjs"
113
- ],
114
102
  "eslintConfig": {
115
103
  "extends": "@adonisjs/eslint-config/package"
116
104
  },
117
105
  "prettier": "@adonisjs/prettier-config",
118
- "commitlint": {
119
- "extends": [
120
- "@commitlint/config-conventional"
121
- ]
122
- },
123
106
  "publishConfig": {
124
107
  "access": "public",
125
- "tag": "latest"
108
+ "tag": "next"
126
109
  },
127
110
  "np": {
128
111
  "message": "chore(release): %s",
129
- "tag": "latest",
130
- "branch": "main",
112
+ "tag": "next",
113
+ "branch": "next",
131
114
  "anyBranch": false
132
115
  },
133
116
  "c8": {
@@ -139,8 +122,5 @@
139
122
  "tests/**",
140
123
  "tests_helpers/**"
141
124
  ]
142
- },
143
- "directories": {
144
- "test": "tests"
145
125
  }
146
126
  }
@@ -1,3 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- declare const _default: import("util").DebugLogger;
3
- export default _default;
@@ -1,10 +0,0 @@
1
- /*
2
- * @adonisjs/vite
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { debuglog } from 'node:util';
10
- export default debuglog('adonisjs:vite');
@@ -1,5 +0,0 @@
1
- import { ViteOptions } from './types.js';
2
- /**
3
- * Define the backend config for resolving vite assets
4
- */
5
- export declare function defineConfig(config: Partial<ViteOptions>): ViteOptions;
@@ -1,20 +0,0 @@
1
- import { ResolvedConfig, UserConfig, AliasOptions } from 'vite';
2
- import { PluginFullOptions } from './types.js';
3
- export declare class ConfigResolver {
4
- static resolvedConfig?: ResolvedConfig;
5
- /**
6
- * Resolve the `config.base` value
7
- */
8
- static resolveBase(config: UserConfig, options: PluginFullOptions, command: 'build' | 'serve'): string;
9
- /**
10
- * Resolve the `config.resolve.alias` value
11
- *
12
- * Basically we are merging the user defined alias with the
13
- * default alias.
14
- */
15
- static resolveAlias(config: UserConfig): AliasOptions;
16
- /**
17
- * Resolve the `config.build.outDir` value
18
- */
19
- static resolveOutDir(config: UserConfig, options: PluginFullOptions): string;
20
- }
@@ -1,46 +0,0 @@
1
- /*
2
- * @adonisjs/vite
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { addTrailingSlash } from './utils.js';
10
- export class ConfigResolver {
11
- static resolvedConfig;
12
- /**
13
- * Resolve the `config.base` value
14
- */
15
- static resolveBase(config, options, command) {
16
- if (config.base) {
17
- return config.base;
18
- }
19
- if (command === 'build') {
20
- return addTrailingSlash(options.assetsUrl);
21
- }
22
- return '/';
23
- }
24
- /**
25
- * Resolve the `config.resolve.alias` value
26
- *
27
- * Basically we are merging the user defined alias with the
28
- * default alias.
29
- */
30
- static resolveAlias(config) {
31
- const defaultAlias = { '@/': `/resources/js/` };
32
- if (Array.isArray(config.resolve?.alias)) {
33
- return [
34
- ...(config.resolve?.alias ?? []),
35
- Object.entries(defaultAlias).map(([find, replacement]) => ({ find, replacement })),
36
- ];
37
- }
38
- return { ...defaultAlias, ...config.resolve?.alias };
39
- }
40
- /**
41
- * Resolve the `config.build.outDir` value
42
- */
43
- static resolveOutDir(config, options) {
44
- return config.build?.outDir ?? options.buildDirectory;
45
- }
46
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * Resolves a page component.
3
- */
4
- export declare function resolvePageComponent(name: string, pages: Record<string, any>): Promise<any>;
@@ -1,22 +0,0 @@
1
- /*
2
- * @adonisjs/vite
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- /**
10
- * Resolves a page component.
11
- */
12
- export async function resolvePageComponent(name, pages) {
13
- const path = Object.keys(pages)
14
- .sort((a, b) => a.length - b.length)
15
- .find((filepath) => filepath.endsWith(name));
16
- if (!path) {
17
- throw new Error(`Page component "${name}" could not be found.`);
18
- }
19
- let component = typeof pages[path] === 'function' ? await pages[path]() : pages[path];
20
- component = component.default ?? component;
21
- return component;
22
- }
@@ -1,14 +0,0 @@
1
- export declare class HotFile {
2
- #private;
3
- constructor(path: string);
4
- /**
5
- * Write the hot file
6
- */
7
- write(data: {
8
- url: string;
9
- }): Promise<void>;
10
- /**
11
- * Delete the hot file
12
- */
13
- clean(): void;
14
- }