@adonisjs/assembler 7.8.1 → 8.0.0-next.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 +8 -23
- package/build/chunk-RR4HCA4M.js +7 -0
- package/build/index.d.ts +3 -3
- package/build/index.js +688 -666
- package/build/src/bundler.d.ts +28 -7
- package/build/src/code_transformer/main.d.ts +30 -2
- package/build/src/code_transformer/main.js +80 -14
- package/build/src/code_transformer/rc_file_transformer.d.ts +7 -5
- package/build/src/dev_server.d.ts +42 -14
- package/build/src/file_system.d.ts +60 -0
- package/build/src/test_runner.d.ts +30 -6
- package/build/src/types/code_transformer.d.ts +61 -0
- package/build/src/types/common.d.ts +149 -0
- package/build/src/types/hooks.d.ts +65 -0
- package/build/src/types/main.d.ts +3 -0
- package/build/src/types/main.js +0 -0
- package/build/src/{helpers.d.ts → utils.d.ts} +28 -10
- package/package.json +37 -46
- package/build/index.js.map +0 -1
- package/build/src/assets_dev_server.d.ts +0 -31
- package/build/src/code_transformer/main.js.map +0 -1
- package/build/src/hooks.d.ts +0 -29
- package/build/src/types.d.ts +0 -245
- package/build/src/types.js +0 -1
- package/build/src/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -17,29 +17,10 @@ Assembler is built around the following goals.
|
|
|
17
17
|
- House all development APIs needed by AdonisJS. Therefore, the scope of the Assembler might increase over time.
|
|
18
18
|
|
|
19
19
|
## Dev server
|
|
20
|
-
|
|
20
|
+
The development server can be started using the `DevServer` class. It will run `bin/server.ts` file from the AdonisJS project as a child process and monitor it for changes (in both HMR and watcher modes).
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
You might be tempted to use the Node.js built-in file watcher with the `--watch` flag. However, the Node.js file watcher does not integrate with TypeScript. As a result, you will be tweaking its configuration options to get an ideal experience.
|
|
22
|
+
Every time there is a file change, the `DevServer` will execute the file watcher hooks and if needed will restart the development server.
|
|
24
23
|
|
|
25
|
-
On the other hand, the Assembler file watcher takes the following approach.
|
|
26
|
-
|
|
27
|
-
- Parses the `tsconfig.json` file to collect the list of files that are part of your TypeScript project. As a result, if you ever want to ignore any file, you do it directly within the `tsconfig.json` file, and the watcher will pick it up.
|
|
28
|
-
- It uses the `metaFiles` array defined inside the `adonisrc.ts` file to watch additional files that are not `.js` or `.ts`. It may be the Edge templates, markdown files, YAML files, etc.
|
|
29
|
-
|
|
30
|
-
### Starting the asset bundler server
|
|
31
|
-
If you create a full-stack application, the chances of using Webpack or Vite are high. Instead of starting your assets bundler inside a separate process, you can also rely on Assembler to start a parallel process for the assets bundler.
|
|
32
|
-
|
|
33
|
-
The [`node ace serve` command](https://github.com/adonisjs/core/blob/next/commands/serve.ts#L88) detects the assets bundler used by your AdonisJS project and passes it to Assembler.
|
|
34
|
-
|
|
35
|
-
Therefore, if you run the `serve` command with a `vite.config.js` file, you will notice that the Assembler will start both Vite and the AdonisJS HTTP server.
|
|
36
|
-
|
|
37
|
-
### Picking a random port
|
|
38
|
-
The PORT on which an AdonisJS application should run is configured inside the `.env` file of your AdonisJS application. However, you will often start multiple projects together and have to edit the `.env` file to ensure both projects run on different ports.
|
|
39
|
-
|
|
40
|
-
With Assembler, you do not have to edit the `.env` files since Assembler will pick a random port of your application if the configured one is already in use.
|
|
41
|
-
|
|
42
|
-
### Usage
|
|
43
24
|
You may import and use the `DevServer` as follows.
|
|
44
25
|
|
|
45
26
|
```ts
|
|
@@ -92,9 +73,14 @@ devServer.onClose((exitCode) => {
|
|
|
92
73
|
await devServer.runAndWatch(ts)
|
|
93
74
|
```
|
|
94
75
|
|
|
95
|
-
You may start the dev server
|
|
76
|
+
You may start the dev server in HMR mode by setting `hmr: true` and calling the `start` method.
|
|
96
77
|
|
|
97
78
|
```ts
|
|
79
|
+
const devServer = new DevServer(appRoot, {
|
|
80
|
+
hmr: true,
|
|
81
|
+
// ...rest of the config
|
|
82
|
+
})
|
|
83
|
+
|
|
98
84
|
await devServer.start()
|
|
99
85
|
```
|
|
100
86
|
|
|
@@ -166,7 +152,6 @@ await runner.run()
|
|
|
166
152
|
The `Bundler` is used to create the production build of an AdonisJS application. The following steps are performed to generate the build.
|
|
167
153
|
|
|
168
154
|
- Clean up the existing build directory.
|
|
169
|
-
- Compile frontend assets (if an assets bundler is configured).
|
|
170
155
|
- Create JavaScript build using `tsc` (The TypeScript's official compiler).
|
|
171
156
|
- Copy the `ace.js` file to the build folder. Since the ace file ends with the `.js` extension, it is not compiled by the TypeScript compiler.
|
|
172
157
|
- Copy `package.json` and the **lock-file of the package manager** you are using to the `build` folder. This operation only supports `bun | npm | yarn | pnpm`. For other bundlers, you will have to copy the lock file manually.
|
package/build/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { Bundler } from './src/bundler.
|
|
2
|
-
export { DevServer } from './src/dev_server.
|
|
3
|
-
export { TestRunner } from './src/test_runner.
|
|
1
|
+
export { Bundler } from './src/bundler.ts';
|
|
2
|
+
export { DevServer } from './src/dev_server.ts';
|
|
3
|
+
export { TestRunner } from './src/test_runner.ts';
|