@adonisjs/assembler 8.0.0-next.15 → 8.0.0-next.16
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/build/{chunk-3GYRM5Y2.js → chunk-HRE5L24F.js} +50 -1
- package/build/{chunk-CX6VPELJ.js → chunk-WG7JQZUU.js} +3 -2
- package/build/{chunk-KAOPWBR3.js → chunk-YFDLKKOA.js} +1 -1
- package/build/index.js +18 -17
- package/build/src/code_scanners/routes_scanner/main.js +2 -2
- package/build/src/dev_server.d.ts +2 -3
- package/build/src/file_system.d.ts +2 -2
- package/build/src/index_generator/main.js +2 -2
- package/build/src/test_runner.d.ts +1 -2
- package/build/src/utils.d.ts +4 -0
- package/package.json +4 -2
|
@@ -26,6 +26,7 @@ import { importDefault } from "@poppinss/utils";
|
|
|
26
26
|
import { copyFile, mkdir } from "fs/promises";
|
|
27
27
|
import { EnvLoader, EnvParser } from "@adonisjs/env";
|
|
28
28
|
import chokidar from "chokidar";
|
|
29
|
+
import { parseTsconfig } from "get-tsconfig";
|
|
29
30
|
import { basename, dirname, isAbsolute, join, relative } from "path";
|
|
30
31
|
var DEFAULT_NODE_ARGS = ["--import=@poppinss/ts-exec", "--enable-source-maps"];
|
|
31
32
|
function parseConfig(cwd, ts) {
|
|
@@ -65,6 +66,29 @@ function parseConfig(cwd, ts) {
|
|
|
65
66
|
}
|
|
66
67
|
return parsedConfig;
|
|
67
68
|
}
|
|
69
|
+
function readTsConfig(cwd) {
|
|
70
|
+
const tsConfigPath = join(cwd, "tsconfig.json");
|
|
71
|
+
debug_default('reading config file from location "%s"', tsConfigPath);
|
|
72
|
+
try {
|
|
73
|
+
const tsConfig = parseTsconfig(tsConfigPath);
|
|
74
|
+
if (tsConfig.include) {
|
|
75
|
+
tsConfig.include = tsConfig.include.map((resolvedPath) => {
|
|
76
|
+
return resolvedPath.replace(`${cwd}/`, "");
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (tsConfig.exclude) {
|
|
80
|
+
tsConfig.exclude = tsConfig.exclude.map((resolvedPath) => {
|
|
81
|
+
return resolvedPath.replace(`${cwd}/`, "");
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
path: tsConfigPath,
|
|
86
|
+
config: tsConfig
|
|
87
|
+
};
|
|
88
|
+
} catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
68
92
|
function runNode(cwd, options) {
|
|
69
93
|
const childProcess = execaNode(options.script, options.scriptArgs, {
|
|
70
94
|
nodeOptions: DEFAULT_NODE_ARGS.concat(options.nodeArgs),
|
|
@@ -244,6 +268,30 @@ var VirtualFileSystem = class {
|
|
|
244
268
|
};
|
|
245
269
|
this.#matcher = picomatch(this.#options.glob ?? DEFAULT_GLOB, this.#picoMatchOptions);
|
|
246
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Currently the PathsResolver relies on a non-standard way of resolving
|
|
273
|
+
* absolute paths or paths with subpath imports. Because of which, the
|
|
274
|
+
* on-disk file could be TypeScript, while the resolved filepath is
|
|
275
|
+
* JavaScript.
|
|
276
|
+
*
|
|
277
|
+
* To overcome this limitation, we start by first looking for a `.ts` file
|
|
278
|
+
* (because of high probability) and then look for `.js` file
|
|
279
|
+
*/
|
|
280
|
+
async #readTSOrJSFile(filePath) {
|
|
281
|
+
if (filePath.endsWith(".js")) {
|
|
282
|
+
try {
|
|
283
|
+
const contents = await readFile(filePath.replace(/\.js$/, ".ts"), "utf-8");
|
|
284
|
+
debug_default('read as TypeScript file "%s"', filePath);
|
|
285
|
+
return contents;
|
|
286
|
+
} catch (error) {
|
|
287
|
+
if (error.code === "ENOENT") {
|
|
288
|
+
return readFile(filePath, "utf-8");
|
|
289
|
+
}
|
|
290
|
+
throw error;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return readFile(filePath, "utf-8");
|
|
294
|
+
}
|
|
247
295
|
/**
|
|
248
296
|
* Scans the filesystem to collect the files. Newly files must
|
|
249
297
|
* be added via the ".add" method.
|
|
@@ -358,7 +406,7 @@ var VirtualFileSystem = class {
|
|
|
358
406
|
debug_default('returning AST nodes from cache "%s"', filePath);
|
|
359
407
|
return cached;
|
|
360
408
|
}
|
|
361
|
-
const fileContents = await
|
|
409
|
+
const fileContents = await this.#readTSOrJSFile(filePath);
|
|
362
410
|
debug_default('parsing "%s" file to AST', filePath);
|
|
363
411
|
this.#astCache.set(filePath, parse(Lang.TypeScript, fileContents).root());
|
|
364
412
|
return this.#astCache.get(filePath);
|
|
@@ -394,6 +442,7 @@ var VirtualFileSystem = class {
|
|
|
394
442
|
export {
|
|
395
443
|
debug_default,
|
|
396
444
|
parseConfig,
|
|
445
|
+
readTsConfig,
|
|
397
446
|
runNode,
|
|
398
447
|
run,
|
|
399
448
|
watch,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
VirtualFileSystem,
|
|
11
11
|
debug_default,
|
|
12
12
|
isRelative
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-HRE5L24F.js";
|
|
14
14
|
|
|
15
15
|
// src/code_scanners/routes_scanner/main.ts
|
|
16
16
|
import { cliui } from "@poppinss/cliui";
|
|
@@ -20,6 +20,7 @@ import StringBuilder from "@poppinss/utils/string_builder";
|
|
|
20
20
|
|
|
21
21
|
// src/paths_resolver.ts
|
|
22
22
|
import { join } from "path";
|
|
23
|
+
import { resolve } from "import-meta-resolve";
|
|
23
24
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
24
25
|
var PathsResolver = class {
|
|
25
26
|
/**
|
|
@@ -34,7 +35,7 @@ var PathsResolver = class {
|
|
|
34
35
|
/**
|
|
35
36
|
* The resolver function used to resolve import specifiers
|
|
36
37
|
*/
|
|
37
|
-
#resolver = (specifier, parentPath) =>
|
|
38
|
+
#resolver = (specifier, parentPath) => resolve(specifier, parentPath);
|
|
38
39
|
constructor(appRoot) {
|
|
39
40
|
this.#appRoot = pathToFileURL(join(appRoot, "index.js")).href;
|
|
40
41
|
}
|
package/build/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FileBuffer,
|
|
3
3
|
IndexGenerator
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YFDLKKOA.js";
|
|
5
5
|
import {
|
|
6
6
|
RoutesScanner
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-WG7JQZUU.js";
|
|
8
8
|
import "./chunk-TIKQQRMX.js";
|
|
9
9
|
import {
|
|
10
10
|
VirtualFileSystem,
|
|
@@ -14,11 +14,12 @@ import {
|
|
|
14
14
|
loadHooks,
|
|
15
15
|
memoize,
|
|
16
16
|
parseConfig,
|
|
17
|
+
readTsConfig,
|
|
17
18
|
run,
|
|
18
19
|
runNode,
|
|
19
20
|
throttle,
|
|
20
21
|
watch
|
|
21
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-HRE5L24F.js";
|
|
22
23
|
|
|
23
24
|
// src/bundler.ts
|
|
24
25
|
import dedent from "dedent";
|
|
@@ -393,16 +394,16 @@ var FileSystem = class {
|
|
|
393
394
|
constructor(cwd, tsConfig, rcFile) {
|
|
394
395
|
this.#cwd = cwd;
|
|
395
396
|
this.#tsConfig = tsConfig;
|
|
396
|
-
const files = tsConfig.
|
|
397
|
+
const files = tsConfig.config.files ?? [];
|
|
397
398
|
const metaFiles = rcFile.metaFiles ?? [];
|
|
398
399
|
const testSuites = rcFile.suites ?? [];
|
|
399
|
-
const outDir = tsConfig.
|
|
400
|
+
const outDir = tsConfig.config.compilerOptions?.outDir;
|
|
400
401
|
for (const file of files) {
|
|
401
402
|
this.#scannedTypeScriptFiles.add(string2.toUnixSlash(file));
|
|
402
403
|
}
|
|
403
|
-
this.#includes = tsConfig.
|
|
404
|
+
this.#includes = tsConfig.config.include || DEFAULT_INCLUDES;
|
|
404
405
|
this.#excludes = ALWAYS_EXCLUDE.concat(
|
|
405
|
-
tsConfig.
|
|
406
|
+
tsConfig.config.exclude || (outDir ? DEFAULT_EXCLUDES.concat(outDir) : DEFAULT_EXCLUDES)
|
|
406
407
|
);
|
|
407
408
|
const metaFilesWithReloads = [];
|
|
408
409
|
const metaFilesWithoutReloads = [];
|
|
@@ -444,10 +445,10 @@ var FileSystem = class {
|
|
|
444
445
|
if ((relativePath.endsWith(".ts") || relativePath.endsWith(".tsx")) && !relativePath.endsWith(".d.ts")) {
|
|
445
446
|
return true;
|
|
446
447
|
}
|
|
447
|
-
if (this.#tsConfig.
|
|
448
|
+
if (this.#tsConfig.config.compilerOptions?.allowJs && relativePath.endsWith(".js")) {
|
|
448
449
|
return true;
|
|
449
450
|
}
|
|
450
|
-
if (this.#tsConfig.
|
|
451
|
+
if (this.#tsConfig.config.compilerOptions?.resolveJsonModule && relativePath.endsWith(".json")) {
|
|
451
452
|
return true;
|
|
452
453
|
}
|
|
453
454
|
return false;
|
|
@@ -1014,8 +1015,8 @@ var DevServer = class _DevServer {
|
|
|
1014
1015
|
* console.error('Failed to initialize dev server')
|
|
1015
1016
|
* }
|
|
1016
1017
|
*/
|
|
1017
|
-
async #init(
|
|
1018
|
-
const tsConfig =
|
|
1018
|
+
async #init(mode) {
|
|
1019
|
+
const tsConfig = readTsConfig(this.cwdPath);
|
|
1019
1020
|
if (!tsConfig) {
|
|
1020
1021
|
this.#onError?.(new RuntimeException("Unable to parse tsconfig file"));
|
|
1021
1022
|
return false;
|
|
@@ -1182,8 +1183,8 @@ var DevServer = class _DevServer {
|
|
|
1182
1183
|
* const devServer = new DevServer(cwd, { hmr: true, hooks: [] })
|
|
1183
1184
|
* await devServer.start(ts)
|
|
1184
1185
|
*/
|
|
1185
|
-
async start(
|
|
1186
|
-
const initiated = await this.#init(
|
|
1186
|
+
async start() {
|
|
1187
|
+
const initiated = await this.#init(this.options.hmr ? "hmr" : "static");
|
|
1187
1188
|
if (!initiated) {
|
|
1188
1189
|
return;
|
|
1189
1190
|
}
|
|
@@ -1214,8 +1215,8 @@ var DevServer = class _DevServer {
|
|
|
1214
1215
|
* const devServer = new DevServer(cwd, { hooks: [] })
|
|
1215
1216
|
* await devServer.startAndWatch(ts, { poll: false })
|
|
1216
1217
|
*/
|
|
1217
|
-
async startAndWatch(
|
|
1218
|
-
const initiated = await this.#init(
|
|
1218
|
+
async startAndWatch(options) {
|
|
1219
|
+
const initiated = await this.#init("watch");
|
|
1219
1220
|
if (!initiated) {
|
|
1220
1221
|
return;
|
|
1221
1222
|
}
|
|
@@ -1579,8 +1580,8 @@ var TestRunner = class {
|
|
|
1579
1580
|
* @param ts - TypeScript module reference for parsing configuration
|
|
1580
1581
|
* @param options - Watch options including polling mode for file system monitoring
|
|
1581
1582
|
*/
|
|
1582
|
-
async runAndWatch(
|
|
1583
|
-
const tsConfig =
|
|
1583
|
+
async runAndWatch(options) {
|
|
1584
|
+
const tsConfig = readTsConfig(this.cwdPath);
|
|
1584
1585
|
if (!tsConfig) {
|
|
1585
1586
|
this.#onError?.(new RuntimeException2("Unable to parse tsconfig file"));
|
|
1586
1587
|
return;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type tsStatic from 'typescript';
|
|
2
1
|
import type { DevServerOptions } from './types/common.ts';
|
|
3
2
|
/**
|
|
4
3
|
* Exposes the API to start the development server in HMR, watch or static mode
|
|
@@ -128,7 +127,7 @@ export declare class DevServer {
|
|
|
128
127
|
* const devServer = new DevServer(cwd, { hmr: true, hooks: [] })
|
|
129
128
|
* await devServer.start(ts)
|
|
130
129
|
*/
|
|
131
|
-
start(
|
|
130
|
+
start(): Promise<void>;
|
|
132
131
|
/**
|
|
133
132
|
* Starts the development server in watch mode and restarts on file changes
|
|
134
133
|
*
|
|
@@ -144,7 +143,7 @@ export declare class DevServer {
|
|
|
144
143
|
* const devServer = new DevServer(cwd, { hooks: [] })
|
|
145
144
|
* await devServer.startAndWatch(ts, { poll: false })
|
|
146
145
|
*/
|
|
147
|
-
startAndWatch(
|
|
146
|
+
startAndWatch(options?: {
|
|
148
147
|
poll: boolean;
|
|
149
148
|
}): Promise<void>;
|
|
150
149
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type TsConfigResult } from 'get-tsconfig';
|
|
2
2
|
import { type InspectedFile, type AssemblerRcFile } from './types/common.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Exposes an intutive API to run actions when different kind of files
|
|
@@ -83,7 +83,7 @@ export declare class FileSystem {
|
|
|
83
83
|
* @param tsConfig - Parsed TypeScript configuration
|
|
84
84
|
* @param rcFile - AdonisJS RC file configuration
|
|
85
85
|
*/
|
|
86
|
-
constructor(cwd: string, tsConfig:
|
|
86
|
+
constructor(cwd: string, tsConfig: TsConfigResult, rcFile: AssemblerRcFile);
|
|
87
87
|
/**
|
|
88
88
|
* Returns true if the file should be watched. Chokidar sends
|
|
89
89
|
* absolute unix paths to the ignored callback.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type tsStatic from 'typescript';
|
|
2
1
|
import type { TestRunnerOptions } from './types/common.ts';
|
|
3
2
|
/**
|
|
4
3
|
* Exposes the API to run Japa tests and optionally watch for file
|
|
@@ -111,7 +110,7 @@ export declare class TestRunner {
|
|
|
111
110
|
* @param ts - TypeScript module reference for parsing configuration
|
|
112
111
|
* @param options - Watch options including polling mode for file system monitoring
|
|
113
112
|
*/
|
|
114
|
-
runAndWatch(
|
|
113
|
+
runAndWatch(options?: {
|
|
115
114
|
poll: boolean;
|
|
116
115
|
}): Promise<void>;
|
|
117
116
|
}
|
package/build/src/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Hooks from '@poppinss/hooks';
|
|
2
2
|
import type tsStatic from 'typescript';
|
|
3
3
|
import { type ChokidarOptions } from 'chokidar';
|
|
4
|
+
import { type TsConfigResult } from 'get-tsconfig';
|
|
4
5
|
import type { RunScriptOptions } from './types/common.ts';
|
|
5
6
|
import { type AllHooks, type HookParams } from './types/hooks.ts';
|
|
6
7
|
/**
|
|
@@ -10,11 +11,14 @@ import { type AllHooks, type HookParams } from './types/hooks.ts';
|
|
|
10
11
|
* handling diagnostic errors and returning a parsed configuration that can be
|
|
11
12
|
* used by other TypeScript operations.
|
|
12
13
|
*
|
|
14
|
+
* @deprecated While we are experimenting with the readTsConfig method
|
|
15
|
+
*
|
|
13
16
|
* @param cwd - The current working directory URL or string path
|
|
14
17
|
* @param ts - TypeScript module reference
|
|
15
18
|
* @returns Parsed TypeScript configuration or undefined if parsing failed
|
|
16
19
|
*/
|
|
17
20
|
export declare function parseConfig(cwd: URL | string, ts: typeof tsStatic): tsStatic.ParsedCommandLine | undefined;
|
|
21
|
+
export declare function readTsConfig(cwd: string): TsConfigResult | null;
|
|
18
22
|
/**
|
|
19
23
|
* Runs a Node.js script as a child process and inherits the stdio streams
|
|
20
24
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/assembler",
|
|
3
3
|
"description": "Provides utilities to run AdonisJS development server and build project for production",
|
|
4
|
-
"version": "8.0.0-next.
|
|
4
|
+
"version": "8.0.0-next.16",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"release": "release-it",
|
|
35
35
|
"version": "npm run build",
|
|
36
36
|
"prepublishOnly": "npm run build",
|
|
37
|
-
"quick:test": "cross-env NODE_DEBUG=adonisjs:assembler node --enable-source-maps --import=@poppinss/ts-exec
|
|
37
|
+
"quick:test": "cross-env NODE_DEBUG=adonisjs:assembler node --enable-source-maps --import=@poppinss/ts-exec bin/test.ts"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@adonisjs/eslint-config": "^3.0.0-next.0",
|
|
@@ -74,6 +74,8 @@
|
|
|
74
74
|
"fast-glob": "^3.3.3",
|
|
75
75
|
"fdir": "^6.5.0",
|
|
76
76
|
"get-port": "^7.1.0",
|
|
77
|
+
"get-tsconfig": "^4.13.0",
|
|
78
|
+
"import-meta-resolve": "^4.2.0",
|
|
77
79
|
"junk": "^4.0.1",
|
|
78
80
|
"open": "^10.2.0",
|
|
79
81
|
"parse-imports": "^3.0.0",
|