@travetto/compiler 3.0.0 → 3.0.1
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/package.json +5 -5
- package/src/state.ts +2 -1
- package/src/watch.ts +30 -13
- package/support/launcher.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/compiler",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "The compiler infrastructure for the Travetto framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@parcel/watcher": "^2.1.0",
|
|
34
|
-
"@travetto/manifest": "^3.0.
|
|
35
|
-
"@travetto/terminal": "^3.0.
|
|
36
|
-
"@travetto/transformer": "^3.0.
|
|
34
|
+
"@travetto/manifest": "^3.0.1",
|
|
35
|
+
"@travetto/terminal": "^3.0.1",
|
|
36
|
+
"@travetto/transformer": "^3.0.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@travetto/cli": "^3.0.
|
|
39
|
+
"@travetto/cli": "^3.0.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependenciesMeta": {
|
|
42
42
|
"@travetto/cli": {
|
package/src/state.ts
CHANGED
|
@@ -110,10 +110,11 @@ export class CompilerState implements ts.CompilerHost {
|
|
|
110
110
|
} else if (inputFile.endsWith('.js')) {
|
|
111
111
|
this.writeFile(this.#inputToEntry.get(inputFile)!.output!, ts.transpile(this.readFile(inputFile)!, this.#compilerOptions), false);
|
|
112
112
|
} else if (inputFile.endsWith('.ts')) {
|
|
113
|
+
const source = this.readFile(inputFile);
|
|
113
114
|
return program.emit(
|
|
114
115
|
program.getSourceFile(inputFile)!,
|
|
115
116
|
(...args) => this.writeFile(...args), undefined, false,
|
|
116
|
-
this.#transformerManager.get()
|
|
117
|
+
/^[/][/]\s*@skip-transformers/.test(source!) ? undefined : this.#transformerManager.get()
|
|
117
118
|
);
|
|
118
119
|
}
|
|
119
120
|
}
|
package/src/watch.ts
CHANGED
|
@@ -3,7 +3,7 @@ import fs from 'fs/promises';
|
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
ManifestContext, ManifestModuleUtil, ManifestUtil, WatchEvent, ManifestModuleFolderType,
|
|
6
|
-
ManifestModuleFileType, path, ManifestModule, watchFolders, WatchEventListener
|
|
6
|
+
ManifestModuleFileType, path, ManifestModule, watchFolders, WatchEventListener, watchFolderImmediate, WatchConfig
|
|
7
7
|
} from '@travetto/manifest';
|
|
8
8
|
import { getManifestContext } from '@travetto/manifest/bin/context';
|
|
9
9
|
|
|
@@ -125,18 +125,35 @@ export class CompilerWatcher {
|
|
|
125
125
|
/**
|
|
126
126
|
* Watch files based on root index
|
|
127
127
|
*/
|
|
128
|
-
watchFiles(emit: CompileEmitter): Promise<() => Promise<void>> {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
128
|
+
async watchFiles(emit: CompileEmitter): Promise<() => Promise<void>> {
|
|
129
|
+
let watchRoot: (() => Promise<void>) | undefined = undefined;
|
|
130
|
+
|
|
131
|
+
const idx = this.#state.manifestIndex;
|
|
132
|
+
const modules = [...idx.getModuleList('all')].map(x => idx.getModule(x)!);
|
|
133
|
+
const remove = (outputFile: string): Promise<void> => fs.rm(outputFile, { force: true });
|
|
134
|
+
const handler = this.#getWatcher({ create: emit, update: emit, delete: remove });
|
|
135
|
+
const options: WatchConfig = {
|
|
136
|
+
filter: ev => ev.file.endsWith('.ts') || ev.file.endsWith('.js') || ev.file.endsWith('package.json'),
|
|
137
|
+
ignore: ['node_modules']
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const moduleFolders = modules
|
|
141
|
+
.filter(x => !idx.manifest.monoRepo || x.sourcePath !== idx.manifest.workspacePath)
|
|
142
|
+
.map(x => [x.sourcePath, x.sourcePath] as const);
|
|
143
|
+
|
|
144
|
+
// Add monorepo folders
|
|
145
|
+
if (idx.manifest.monoRepo) {
|
|
146
|
+
const mono = modules.find(x => x.sourcePath === idx.manifest.workspacePath)!;
|
|
147
|
+
for (const folder of Object.keys(mono.files)) {
|
|
148
|
+
if (!folder.startsWith('$')) {
|
|
149
|
+
moduleFolders.push([path.resolve(mono.sourcePath, folder), mono.sourcePath]);
|
|
150
|
+
}
|
|
139
151
|
}
|
|
140
|
-
|
|
152
|
+
watchRoot = await watchFolderImmediate(mono.sourcePath, handler, options);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const watchAll = await watchFolders(moduleFolders, handler, options);
|
|
156
|
+
|
|
157
|
+
return () => Promise.all([watchRoot?.(), watchAll()]).then(() => { });
|
|
141
158
|
}
|
|
142
159
|
}
|
package/support/launcher.ts
CHANGED
|
@@ -145,7 +145,7 @@ export async function launch(ctx: ManifestContext, root: ManifestContext, op?: '
|
|
|
145
145
|
// TODO: Externalize somehow?
|
|
146
146
|
const outputPath = path.resolve(ctx.workspacePath, ctx.outputFolder);
|
|
147
147
|
process.env.TRV_MANIFEST = path.resolve(outputPath, 'node_modules', ctx.mainModule);
|
|
148
|
-
const cliMain = path.join(outputPath, 'node_modules', '@travetto/cli/support/cli.js');
|
|
148
|
+
const cliMain = path.join(outputPath, 'node_modules', '@travetto/cli/support/entry.cli.js');
|
|
149
149
|
return import(cliMain);
|
|
150
150
|
}
|
|
151
151
|
}
|