@adonisjs/vite 0.0.1-9 → 2.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.
- package/README.md +3 -6
- package/build/index.d.ts +0 -1
- package/build/index.js +0 -1
- package/build/providers/vite_provider.d.ts +14 -5
- package/build/providers/vite_provider.js +49 -16
- package/build/src/backend/debug.d.ts +1 -1
- package/build/src/backend/define_config.d.ts +1 -1
- package/build/src/backend/define_config.js +4 -0
- package/build/src/backend/{edge_plugin_vite.d.ts → plugins/edge.d.ts} +1 -1
- package/build/src/backend/{edge_plugin_vite.js → plugins/edge.js} +25 -4
- package/build/src/backend/{types/main.d.ts → types.d.ts} +7 -0
- package/build/src/backend/vite.d.ts +14 -3
- package/build/src/backend/vite.js +30 -12
- package/build/src/client/main.d.ts +5 -0
- package/build/src/client/main.js +1 -2
- package/build/src/client/utils.js +14 -0
- package/build/stubs/client_config.stub +4 -4
- package/build/stubs/config.stub +3 -3
- package/build/stubs/js_entrypoint.stub +3 -3
- package/package.json +42 -31
- package/build/src/backend/types/extended.d.ts +0 -14
- package/build/src/backend/types/main.js +0 -9
- /package/build/src/backend/{types/extended.js → types.js} +0 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<br />
|
|
4
4
|
|
|
5
|
-
[![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]
|
|
5
|
+
[![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]
|
|
6
6
|
|
|
7
7
|
## Introduction
|
|
8
8
|
Package to add [Vite](https://vitejs.dev/) as an assets bundler to AdonisJS.
|
|
@@ -21,8 +21,8 @@ In order to ensure that the AdonisJS community is welcoming to all, please revie
|
|
|
21
21
|
## License
|
|
22
22
|
AdonisJS static files middleware is open-sourced software licensed under the [MIT license](LICENSE.md).
|
|
23
23
|
|
|
24
|
-
[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/vite/
|
|
25
|
-
[gh-workflow-url]: https://github.com/adonisjs/vite/actions/workflows/
|
|
24
|
+
[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/vite/checks.yml?style=for-the-badge
|
|
25
|
+
[gh-workflow-url]: https://github.com/adonisjs/vite/actions/workflows/checks.yml "Github action"
|
|
26
26
|
|
|
27
27
|
[npm-image]: https://img.shields.io/npm/v/@adonisjs/vite/latest.svg?style=for-the-badge&logo=npm
|
|
28
28
|
[npm-url]: https://www.npmjs.com/package/@adonisjs/vite/v/latest "npm"
|
|
@@ -31,6 +31,3 @@ AdonisJS static files middleware is open-sourced software licensed under the [MI
|
|
|
31
31
|
|
|
32
32
|
[license-url]: LICENSE.md
|
|
33
33
|
[license-image]: https://img.shields.io/github/license/adonisjs/vite?style=for-the-badge
|
|
34
|
-
|
|
35
|
-
[snyk-image]: https://img.shields.io/snyk/vulnerabilities/github/adonisjs/vite?label=Snyk%20Vulnerabilities&style=for-the-badge
|
|
36
|
-
[snyk-url]: https://snyk.io/test/github/adonisjs/vite?targetFile=package.json "snyk"
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
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 './src/backend/types/extended.js';
|
|
10
9
|
export { configure } from './configure.js';
|
|
11
10
|
export { stubsRoot } from './stubs/index.js';
|
|
12
11
|
export { Vite } from './src/backend/vite.js';
|
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
import type { Edge } from 'edge.js';
|
|
2
1
|
import type { ApplicationService } from '@adonisjs/core/types';
|
|
2
|
+
import type { Vite } from '../src/backend/vite.js';
|
|
3
|
+
/**
|
|
4
|
+
* Extend the container bindings
|
|
5
|
+
*/
|
|
6
|
+
declare module '@adonisjs/core/types' {
|
|
7
|
+
interface ContainerBindings {
|
|
8
|
+
vite: Vite;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
3
11
|
export default class ViteServiceProvider {
|
|
4
12
|
protected app: ApplicationService;
|
|
5
13
|
constructor(app: ApplicationService);
|
|
6
14
|
/**
|
|
7
|
-
*
|
|
15
|
+
* Registers edge plugin when edge is installed
|
|
8
16
|
*/
|
|
9
|
-
protected
|
|
10
|
-
register(): void;
|
|
17
|
+
protected registerEdgePlugin(): Promise<void>;
|
|
11
18
|
/**
|
|
12
|
-
*
|
|
19
|
+
* Registers CSP keywords when @adonisjs/shield is installed
|
|
13
20
|
*/
|
|
21
|
+
protected registerShieldKeywords(): Promise<void>;
|
|
22
|
+
register(): void;
|
|
14
23
|
boot(): Promise<void>;
|
|
15
24
|
}
|
|
@@ -13,16 +13,56 @@ export default class ViteServiceProvider {
|
|
|
13
13
|
this.app = app;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Registers edge plugin when edge is installed
|
|
17
17
|
*/
|
|
18
|
-
async
|
|
18
|
+
async registerEdgePlugin() {
|
|
19
|
+
if (this.app.usingEdgeJS) {
|
|
20
|
+
const edge = await import('edge.js');
|
|
21
|
+
const vite = await this.app.container.make('vite');
|
|
22
|
+
const { edgePluginVite } = await import('../src/backend/plugins/edge.js');
|
|
23
|
+
edge.default.use(edgePluginVite(vite));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Registers CSP keywords when @adonisjs/shield is installed
|
|
28
|
+
*/
|
|
29
|
+
async registerShieldKeywords() {
|
|
30
|
+
let cspKeywords = null;
|
|
19
31
|
try {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
return edge;
|
|
32
|
+
const shieldExports = await import('@adonisjs/shield');
|
|
33
|
+
cspKeywords = shieldExports.cspKeywords;
|
|
23
34
|
}
|
|
24
|
-
catch {
|
|
25
|
-
|
|
35
|
+
catch { }
|
|
36
|
+
if (cspKeywords) {
|
|
37
|
+
debug('Detected @adonisjs/shield package. Adding Vite keywords for CSP policy');
|
|
38
|
+
const vite = await this.app.container.make('vite');
|
|
39
|
+
/**
|
|
40
|
+
* Registering the @viteUrl keyword for CSP directives.
|
|
41
|
+
* Returns http URL to the dev or the CDN server, otherwise
|
|
42
|
+
* an empty string
|
|
43
|
+
*/
|
|
44
|
+
cspKeywords.register('@viteUrl', function () {
|
|
45
|
+
const assetsURL = vite.assetsUrl();
|
|
46
|
+
if (!assetsURL || !assetsURL.startsWith('http://') || assetsURL.startsWith('https://')) {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
return assetsURL;
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Registering the @viteDevUrl keyword for the CSP directives.
|
|
53
|
+
* Returns the dev server URL in development and empty string
|
|
54
|
+
* in prod
|
|
55
|
+
*/
|
|
56
|
+
cspKeywords.register('@viteDevUrl', function () {
|
|
57
|
+
return vite.devUrl();
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* Registering the @viteHmrUrl keyword for the CSP directives.
|
|
61
|
+
* Returns the Websocket URL for the HMR server
|
|
62
|
+
*/
|
|
63
|
+
cspKeywords.register('@viteHmrUrl', function () {
|
|
64
|
+
return vite.devUrl().replace('http://', 'ws://').replace('https://', 'wss://');
|
|
65
|
+
});
|
|
26
66
|
}
|
|
27
67
|
}
|
|
28
68
|
register() {
|
|
@@ -36,15 +76,8 @@ export default class ViteServiceProvider {
|
|
|
36
76
|
});
|
|
37
77
|
});
|
|
38
78
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Extending edge
|
|
41
|
-
*/
|
|
42
79
|
async boot() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const vite = await this.app.container.make('vite');
|
|
46
|
-
const { edgePluginVite } = await import('../src/backend/edge_plugin_vite.js');
|
|
47
|
-
edge.use(edgePluginVite(vite));
|
|
48
|
-
}
|
|
80
|
+
await this.registerEdgePlugin();
|
|
81
|
+
await this.registerShieldKeywords();
|
|
49
82
|
}
|
|
50
83
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
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 { join } from 'node:path';
|
|
9
10
|
/**
|
|
10
11
|
* Define the backend config for resolving vite assets
|
|
11
12
|
*/
|
|
@@ -14,6 +15,9 @@ export function defineConfig(config) {
|
|
|
14
15
|
buildDirectory: 'public/assets',
|
|
15
16
|
hotFile: 'public/assets/hot.json',
|
|
16
17
|
assetsUrl: '/assets',
|
|
18
|
+
manifestFile: config.buildDirectory
|
|
19
|
+
? join(config.buildDirectory, '.vite/manifest.json')
|
|
20
|
+
: 'public/assets/.vite/manifest.json',
|
|
17
21
|
...config,
|
|
18
22
|
};
|
|
19
23
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { EdgeError } from 'edge-error';
|
|
10
|
-
import debug from '
|
|
10
|
+
import debug from '../debug.js';
|
|
11
11
|
/**
|
|
12
12
|
* The edge plugin for vite to share vite service with edge
|
|
13
13
|
* and register custom tags
|
|
@@ -22,11 +22,29 @@ export const edgePluginVite = (vite) => {
|
|
|
22
22
|
tagName: 'viteReactRefresh',
|
|
23
23
|
seekable: true,
|
|
24
24
|
block: false,
|
|
25
|
-
compile(
|
|
25
|
+
compile(parser, buffer, token) {
|
|
26
|
+
let attributes = '';
|
|
27
|
+
if (token.properties.jsArg.trim()) {
|
|
28
|
+
/**
|
|
29
|
+
* Converting a single argument to a SequenceExpression so that we
|
|
30
|
+
* work around the following edge cases.
|
|
31
|
+
*
|
|
32
|
+
* - If someone passes an object literal to the tag, ie { nonce: 'foo' }
|
|
33
|
+
* it will be parsed as a LabeledStatement and not an object.
|
|
34
|
+
* - If we wrap the object literal inside parenthesis, ie ({nonce: 'foo'})
|
|
35
|
+
* then we will end up messing other expressions like a variable reference
|
|
36
|
+
* , or a member expression and so on.
|
|
37
|
+
* - So the best bet is to convert user supplied argument to a sequence expression
|
|
38
|
+
* and hence ignore it during stringification.
|
|
39
|
+
*/
|
|
40
|
+
const jsArg = `a,${token.properties.jsArg}`;
|
|
41
|
+
const parsed = parser.utils.transformAst(parser.utils.generateAST(jsArg, token.loc, token.filename), token.filename, parser);
|
|
42
|
+
attributes = parser.utils.stringify(parsed.expressions[1]);
|
|
43
|
+
}
|
|
26
44
|
/**
|
|
27
45
|
* Get HMR script
|
|
28
46
|
*/
|
|
29
|
-
buffer.writeExpression(`const __vite_hmr_script = state.vite.getReactHmrScript()`, token.filename, token.loc.start.line);
|
|
47
|
+
buffer.writeExpression(`const __vite_hmr_script = state.vite.getReactHmrScript(${attributes})`, token.filename, token.loc.start.line);
|
|
30
48
|
/**
|
|
31
49
|
* Check if the script exists (only in hot mode)
|
|
32
50
|
*/
|
|
@@ -58,7 +76,10 @@ export const edgePluginVite = (vite) => {
|
|
|
58
76
|
}
|
|
59
77
|
const parsed = parser.utils.transformAst(parser.utils.generateAST(token.properties.jsArg, token.loc, token.filename), token.filename, parser);
|
|
60
78
|
const entrypoints = parser.utils.stringify(parsed);
|
|
61
|
-
|
|
79
|
+
const methodCall = parsed.type === 'SequenceExpression'
|
|
80
|
+
? `generateEntryPointsTags${entrypoints}`
|
|
81
|
+
: `generateEntryPointsTags(${entrypoints})`;
|
|
82
|
+
buffer.outputExpression(`state.vite.${methodCall}.join('\\n')`, token.filename, token.loc.start.line, false);
|
|
62
83
|
},
|
|
63
84
|
});
|
|
64
85
|
};
|
|
@@ -45,6 +45,13 @@ export type ViteOptions = {
|
|
|
45
45
|
* @default 'public/assets'
|
|
46
46
|
*/
|
|
47
47
|
buildDirectory: string;
|
|
48
|
+
/**
|
|
49
|
+
* Path to the manifest file relative from the root of
|
|
50
|
+
* the application
|
|
51
|
+
*
|
|
52
|
+
* @default 'public/assets/.vite/manifest.json'
|
|
53
|
+
*/
|
|
54
|
+
manifestFile: string;
|
|
48
55
|
/**
|
|
49
56
|
* The URL to prefix when generating assets URLs. For example: This
|
|
50
57
|
* could the CDN URL when generating the production build
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Manifest } from 'vite';
|
|
2
|
-
import type { AdonisViteElement, ViteOptions } from './types
|
|
2
|
+
import type { AdonisViteElement, ViteOptions } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Vite class exposes the APIs to generate tags and URLs for
|
|
5
5
|
* assets processed using vite.
|
|
@@ -10,7 +10,18 @@ export declare class Vite {
|
|
|
10
10
|
/**
|
|
11
11
|
* Generate tags for the entry points
|
|
12
12
|
*/
|
|
13
|
-
generateEntryPointsTags(entryPoints: string[] | string): AdonisViteElement[];
|
|
13
|
+
generateEntryPointsTags(entryPoints: string[] | string, attributes?: Record<string, any>): AdonisViteElement[];
|
|
14
|
+
/**
|
|
15
|
+
* Returns the dev server URL when running in hot
|
|
16
|
+
* mode. Otherwise an empty string
|
|
17
|
+
*/
|
|
18
|
+
devUrl(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the dev server URL when running in hot
|
|
21
|
+
* mode, otherwise returns the explicitly configured
|
|
22
|
+
* "assets" URL
|
|
23
|
+
*/
|
|
24
|
+
assetsUrl(): string | undefined;
|
|
14
25
|
/**
|
|
15
26
|
* Returns path to a given asset file
|
|
16
27
|
*/
|
|
@@ -24,5 +35,5 @@ export declare class Vite {
|
|
|
24
35
|
/**
|
|
25
36
|
* Returns the script needed for the HMR working with React
|
|
26
37
|
*/
|
|
27
|
-
getReactHmrScript(): AdonisViteElement | null;
|
|
38
|
+
getReactHmrScript(attributes?: Record<string, any>): AdonisViteElement | null;
|
|
28
39
|
}
|
|
@@ -6,7 +6,6 @@
|
|
|
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 { join } from 'node:path';
|
|
10
9
|
import { existsSync, readFileSync } from 'node:fs';
|
|
11
10
|
import debug from './debug.js';
|
|
12
11
|
import { makeAttributes, uniqBy } from './utils.js';
|
|
@@ -15,10 +14,6 @@ import { makeAttributes, uniqBy } from './utils.js';
|
|
|
15
14
|
* assets processed using vite.
|
|
16
15
|
*/
|
|
17
16
|
export class Vite {
|
|
18
|
-
/**
|
|
19
|
-
* Manifest file name
|
|
20
|
-
*/
|
|
21
|
-
#manifestFilename = 'manifest.json';
|
|
22
17
|
/**
|
|
23
18
|
* We cache the manifest file content in production
|
|
24
19
|
* to avoid reading the file multiple times
|
|
@@ -122,12 +117,13 @@ export class Vite {
|
|
|
122
117
|
/**
|
|
123
118
|
* Returns the script needed for the HMR working with Vite
|
|
124
119
|
*/
|
|
125
|
-
#getViteHmrScript() {
|
|
120
|
+
#getViteHmrScript(attributes) {
|
|
126
121
|
return this.#generateElement({
|
|
127
122
|
tag: 'script',
|
|
128
123
|
attributes: {
|
|
129
124
|
type: 'module',
|
|
130
125
|
src: this.#hotAsset('@vite/client'),
|
|
126
|
+
...attributes,
|
|
131
127
|
},
|
|
132
128
|
children: [],
|
|
133
129
|
});
|
|
@@ -137,7 +133,7 @@ export class Vite {
|
|
|
137
133
|
* Also adds the @vite/client script
|
|
138
134
|
*/
|
|
139
135
|
#generateEntryPointsTagsForHotMode(entryPoints, attributes) {
|
|
140
|
-
const viteHmr = this.#getViteHmrScript();
|
|
136
|
+
const viteHmr = this.#getViteHmrScript(attributes);
|
|
141
137
|
const tags = entryPoints.map((entrypoint) => this.#generateTag(entrypoint, attributes));
|
|
142
138
|
return viteHmr ? [viteHmr].concat(tags) : tags;
|
|
143
139
|
}
|
|
@@ -195,12 +191,33 @@ export class Vite {
|
|
|
195
191
|
/**
|
|
196
192
|
* Generate tags for the entry points
|
|
197
193
|
*/
|
|
198
|
-
generateEntryPointsTags(entryPoints) {
|
|
194
|
+
generateEntryPointsTags(entryPoints, attributes) {
|
|
199
195
|
entryPoints = Array.isArray(entryPoints) ? entryPoints : [entryPoints];
|
|
200
196
|
if (this.#isRunningHot()) {
|
|
201
|
-
return this.#generateEntryPointsTagsForHotMode(entryPoints);
|
|
197
|
+
return this.#generateEntryPointsTagsForHotMode(entryPoints, attributes);
|
|
198
|
+
}
|
|
199
|
+
return this.#generateEntryPointsTagsWithManifest(entryPoints, attributes);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Returns the dev server URL when running in hot
|
|
203
|
+
* mode. Otherwise an empty string
|
|
204
|
+
*/
|
|
205
|
+
devUrl() {
|
|
206
|
+
if (this.#isRunningHot()) {
|
|
207
|
+
return this.#readHotFile().url;
|
|
208
|
+
}
|
|
209
|
+
return '';
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Returns the dev server URL when running in hot
|
|
213
|
+
* mode, otherwise returns the explicitly configured
|
|
214
|
+
* "assets" URL
|
|
215
|
+
*/
|
|
216
|
+
assetsUrl() {
|
|
217
|
+
if (this.#isRunningHot()) {
|
|
218
|
+
return this.#readHotFile().url;
|
|
202
219
|
}
|
|
203
|
-
return this.#
|
|
220
|
+
return this.#options.assetsUrl;
|
|
204
221
|
}
|
|
205
222
|
/**
|
|
206
223
|
* Returns path to a given asset file
|
|
@@ -222,14 +239,14 @@ export class Vite {
|
|
|
222
239
|
throw new Error('Cannot read the manifest file when running in hot mode');
|
|
223
240
|
}
|
|
224
241
|
if (!this.#manifestCache) {
|
|
225
|
-
this.#manifestCache = this.#readFileAsJSON(
|
|
242
|
+
this.#manifestCache = this.#readFileAsJSON(this.#options.manifestFile);
|
|
226
243
|
}
|
|
227
244
|
return this.#manifestCache;
|
|
228
245
|
}
|
|
229
246
|
/**
|
|
230
247
|
* Returns the script needed for the HMR working with React
|
|
231
248
|
*/
|
|
232
|
-
getReactHmrScript() {
|
|
249
|
+
getReactHmrScript(attributes) {
|
|
233
250
|
if (!this.#isRunningHot()) {
|
|
234
251
|
return null;
|
|
235
252
|
}
|
|
@@ -237,6 +254,7 @@ export class Vite {
|
|
|
237
254
|
tag: 'script',
|
|
238
255
|
attributes: {
|
|
239
256
|
type: 'module',
|
|
257
|
+
...attributes,
|
|
240
258
|
},
|
|
241
259
|
children: [
|
|
242
260
|
'',
|
package/build/src/client/main.js
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import { defu } from 'defu';
|
|
10
10
|
import PluginRestart from 'vite-plugin-restart';
|
|
11
11
|
import { config } from './config.js';
|
|
12
|
-
const VitePluginRestart = PluginRestart;
|
|
13
12
|
/**
|
|
14
13
|
* Vite plugin for adonisjs
|
|
15
14
|
*/
|
|
@@ -20,5 +19,5 @@ export default function adonisjs(options) {
|
|
|
20
19
|
hotFile: 'public/assets/hot.json',
|
|
21
20
|
reload: ['./resources/views/**/*.edge'],
|
|
22
21
|
});
|
|
23
|
-
return [
|
|
22
|
+
return [PluginRestart({ reload: fullOptions.reload }), config(fullOptions)];
|
|
24
23
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
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 { networkInterfaces } from 'node:os';
|
|
9
10
|
/**
|
|
10
11
|
* Resolve the dev server URL from the server address and configuration.
|
|
11
12
|
*/
|
|
@@ -20,6 +21,19 @@ export const resolveDevServerUrl = (address, config) => {
|
|
|
20
21
|
if (host === '::1') {
|
|
21
22
|
host = 'localhost';
|
|
22
23
|
}
|
|
24
|
+
else if (host === '::') {
|
|
25
|
+
const networkAddress = Object.values(networkInterfaces())
|
|
26
|
+
.flatMap((nInterface) => nInterface ?? [])
|
|
27
|
+
.find((detail) => {
|
|
28
|
+
return (detail &&
|
|
29
|
+
detail.address &&
|
|
30
|
+
detail.family === 'IPv4' &&
|
|
31
|
+
!detail.address.includes('127.0.0.1'));
|
|
32
|
+
});
|
|
33
|
+
if (networkAddress) {
|
|
34
|
+
host = networkAddress.address;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
23
37
|
return `${protocol}://${host}:${address.port}`;
|
|
24
38
|
};
|
|
25
39
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
to:
|
|
3
|
-
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.makePath('vite.config.js') })
|
|
3
|
+
}}}
|
|
4
4
|
import { defineConfig } from 'vite'
|
|
5
5
|
import adonisjs from '@adonisjs/vite/client'
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ export default defineConfig({
|
|
|
16
16
|
/**
|
|
17
17
|
* Paths to watch and reload the browser on file change
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
reload: ['resources/views/**/*.edge'],
|
|
20
20
|
}),
|
|
21
21
|
],
|
|
22
22
|
})
|
package/build/stubs/config.stub
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
to:
|
|
3
|
-
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.makePath('resources/js/app.js') })
|
|
3
|
+
}}}
|
|
4
4
|
console.log('Log from JS entrypoint')
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/vite",
|
|
3
3
|
"description": "Vite plugin for Adonis.js",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.16.0"
|
|
7
7
|
},
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"./services/main": "./build/services/vite.js",
|
|
23
23
|
"./vite_provider": "./build/providers/vite_provider.js",
|
|
24
24
|
"./client": "./build/src/client/main.js",
|
|
25
|
-
"./
|
|
25
|
+
"./plugins/edge": "./build/backend/plugins/edge.js",
|
|
26
26
|
"./types": "./build/src/backend/types.js"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
@@ -34,52 +34,63 @@
|
|
|
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
|
-
"
|
|
37
|
+
"precompile": "npm run lint && npm run clean ",
|
|
38
|
+
"compile": "tsc",
|
|
39
|
+
"postcompile": "npm run copy:templates",
|
|
38
40
|
"build": "npm run compile",
|
|
39
|
-
"postbuild": "npm run copy:templates",
|
|
40
41
|
"release": "np",
|
|
41
42
|
"version": "npm run build",
|
|
42
43
|
"prepublishOnly": "npm run build"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"@adonisjs/assembler": "^6.1.3-
|
|
46
|
-
"@adonisjs/core": "^6.1.5-
|
|
47
|
-
"@adonisjs/eslint-config": "^1.1.
|
|
48
|
-
"@adonisjs/prettier-config": "^1.1.
|
|
49
|
-
"@adonisjs/
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"@japa/
|
|
55
|
-
"@japa/
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
46
|
+
"@adonisjs/assembler": "^6.1.3-28",
|
|
47
|
+
"@adonisjs/core": "^6.1.5-32",
|
|
48
|
+
"@adonisjs/eslint-config": "^1.1.9",
|
|
49
|
+
"@adonisjs/prettier-config": "^1.1.9",
|
|
50
|
+
"@adonisjs/session": "^7.0.0-14",
|
|
51
|
+
"@adonisjs/shield": "^8.0.0-9",
|
|
52
|
+
"@adonisjs/tsconfig": "^1.1.9",
|
|
53
|
+
"@commitlint/cli": "^18.4.3",
|
|
54
|
+
"@commitlint/config-conventional": "^18.4.3",
|
|
55
|
+
"@japa/assert": "^2.0.1",
|
|
56
|
+
"@japa/expect-type": "^2.0.0",
|
|
57
|
+
"@japa/file-system": "^2.0.1",
|
|
58
|
+
"@japa/runner": "^3.1.0",
|
|
59
|
+
"@swc/core": "^1.3.99",
|
|
60
|
+
"@types/node": "^20.10.0",
|
|
58
61
|
"c8": "^8.0.0",
|
|
59
62
|
"copyfiles": "^2.4.1",
|
|
60
|
-
"del-cli": "^5.
|
|
61
|
-
"edge.js": "^6.0.0
|
|
62
|
-
"eslint": "^8.
|
|
63
|
+
"del-cli": "^5.1.0",
|
|
64
|
+
"edge.js": "^6.0.0",
|
|
65
|
+
"eslint": "^8.54.0",
|
|
63
66
|
"husky": "^8.0.3",
|
|
64
67
|
"np": "^8.0.4",
|
|
65
|
-
"prettier": "^3.
|
|
66
|
-
"rollup": "^
|
|
68
|
+
"prettier": "^3.1.0",
|
|
69
|
+
"rollup": "^4.6.0",
|
|
67
70
|
"ts-node": "^10.9.1",
|
|
68
|
-
"typescript": "
|
|
69
|
-
"vite": "^
|
|
71
|
+
"typescript": "5.2.2",
|
|
72
|
+
"vite": "^5.0.2"
|
|
70
73
|
},
|
|
71
74
|
"dependencies": {
|
|
72
|
-
"defu": "^6.1.
|
|
73
|
-
"edge-error": "^4.0.0
|
|
74
|
-
"vite-plugin-restart": "^0.
|
|
75
|
+
"defu": "^6.1.3",
|
|
76
|
+
"edge-error": "^4.0.0",
|
|
77
|
+
"vite-plugin-restart": "^0.4.0"
|
|
75
78
|
},
|
|
76
79
|
"peerDependencies": {
|
|
77
|
-
"@adonisjs/core": "^6.1.5-
|
|
78
|
-
"
|
|
80
|
+
"@adonisjs/core": "^6.1.5-32",
|
|
81
|
+
"@adonisjs/shield": "^8.0.0-9",
|
|
82
|
+
"edge.js": "^6.0.0",
|
|
83
|
+
"vite": "^4.0.0 || ^5.0.0"
|
|
79
84
|
},
|
|
80
85
|
"peerDependenciesMeta": {
|
|
86
|
+
"vite": {
|
|
87
|
+
"optional": true
|
|
88
|
+
},
|
|
81
89
|
"edge.js": {
|
|
82
90
|
"optional": true
|
|
91
|
+
},
|
|
92
|
+
"@adonisjs/shield": {
|
|
93
|
+
"optional": true
|
|
83
94
|
}
|
|
84
95
|
},
|
|
85
96
|
"author": "Julien Ripouteau <julien@ripouteau.com>",
|
|
@@ -111,11 +122,11 @@
|
|
|
111
122
|
},
|
|
112
123
|
"publishConfig": {
|
|
113
124
|
"access": "public",
|
|
114
|
-
"tag": "
|
|
125
|
+
"tag": "latest"
|
|
115
126
|
},
|
|
116
127
|
"np": {
|
|
117
128
|
"message": "chore(release): %s",
|
|
118
|
-
"tag": "
|
|
129
|
+
"tag": "latest",
|
|
119
130
|
"branch": "main",
|
|
120
131
|
"anyBranch": false
|
|
121
132
|
},
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Vite } from '../vite.js';
|
|
2
|
-
/**
|
|
3
|
-
* Extend the container bindings
|
|
4
|
-
*/
|
|
5
|
-
declare module '@adonisjs/core/types' {
|
|
6
|
-
interface ContainerBindings {
|
|
7
|
-
vite: Vite;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
declare module 'vite' {
|
|
11
|
-
interface ManifestChunk {
|
|
12
|
-
integrity: string;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
File without changes
|