@travetto/transformer 5.0.0-rc.3 → 5.0.0-rc.5
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 +1 -1
- package/package.json +2 -2
- package/src/importer.ts +5 -1
- package/src/manager.ts +2 -2
- package/src/resolver/service.ts +3 -2
- package/src/state.ts +2 -2
package/README.md
CHANGED
|
@@ -105,7 +105,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
105
105
|
exports.TEST = void 0;
|
|
106
106
|
const tslib_1 = require("tslib");
|
|
107
107
|
const Ⲑ_function_1 = tslib_1.__importStar(require("@travetto/runtime/src/function.js"));
|
|
108
|
-
var ᚕm = ["@travetto/transformer", "doc/upper"];
|
|
108
|
+
var ᚕm = ["@travetto/transformer", "doc/upper.ts"];
|
|
109
109
|
class TEST {
|
|
110
110
|
static Ⲑinit = Ⲑ_function_1.registerFunction(TEST, ᚕm, { hash: 649563175, lines: [1, 9] }, { COMPUTEAGE: { hash: 1286718349, lines: [6, 8, 7] } }, false, false);
|
|
111
111
|
NAME;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/transformer",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.5",
|
|
4
4
|
"description": "Functionality for AST transformations, with transformer registration, and general utils",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"directory": "module/transformer"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@travetto/manifest": "^5.0.0-rc.
|
|
27
|
+
"@travetto/manifest": "^5.0.0-rc.4",
|
|
28
28
|
"tslib": "^2.6.3",
|
|
29
29
|
"typescript": "^5.5.3"
|
|
30
30
|
},
|
package/src/importer.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
|
|
3
|
-
import { PackageUtil, path } from '@travetto/manifest';
|
|
3
|
+
import { ManifestModuleUtil, PackageUtil, path } from '@travetto/manifest';
|
|
4
4
|
|
|
5
5
|
import { AnyType, TransformResolver, ManagedType } from './resolver/types';
|
|
6
6
|
import { ImportUtil } from './util/import';
|
|
@@ -104,6 +104,10 @@ export class ImportManager {
|
|
|
104
104
|
importFile(file: string, name?: string): Import {
|
|
105
105
|
file = this.#resolver.getFileImportName(file);
|
|
106
106
|
|
|
107
|
+
if (file.endsWith('.ts') && !file.endsWith('.d.ts')) {
|
|
108
|
+
file = ManifestModuleUtil.withOutputExtension(file);
|
|
109
|
+
}
|
|
110
|
+
|
|
107
111
|
// Allow for node classes to be imported directly
|
|
108
112
|
if (/@types\/node/.test(file)) {
|
|
109
113
|
file = PackageUtil.resolveImport(file.replace(/.*@types\/node\//, '').replace(D_OR_D_TS_EXT_RE, ''));
|
package/src/manager.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
|
|
3
|
-
import { ManifestIndex } from '@travetto/manifest';
|
|
3
|
+
import { ManifestIndex, ManifestModuleUtil } from '@travetto/manifest';
|
|
4
4
|
|
|
5
5
|
import { NodeTransformer } from './types/visitor';
|
|
6
6
|
import { VisitorFactory } from './visitor';
|
|
@@ -25,7 +25,7 @@ export class TransformerManager {
|
|
|
25
25
|
|
|
26
26
|
for (const file of transformerFiles) { // Exclude based on blacklist
|
|
27
27
|
const entry = manifestIndex.getEntry(file)!;
|
|
28
|
-
transformers.push(...getAllTransformers(await import(entry.import), entry.module));
|
|
28
|
+
transformers.push(...getAllTransformers(await import(ManifestModuleUtil.withOutputExtension(entry.import)), entry.module));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
for (const x of transformers) {
|
package/src/resolver/service.ts
CHANGED
|
@@ -41,14 +41,15 @@ export class SimpleResolver implements TransformResolver {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
return this.#manifestIndex.getEntry(ManifestModuleUtil.getFileType(sourceFile) === 'ts' ? sourceFile : `${sourceFile}.js`) ??
|
|
44
|
-
this.#manifestIndex.getFromImport(ManifestModuleUtil.
|
|
44
|
+
this.#manifestIndex.getFromImport(ManifestModuleUtil.withoutSourceExtension(sourceFile).replace(/^.*node_modules\//, ''));
|
|
45
45
|
}
|
|
46
|
+
|
|
46
47
|
/**
|
|
47
48
|
* Resolve an import name (e.g. @module/path/file) for a file
|
|
48
49
|
*/
|
|
49
50
|
getFileImportName(file: string, removeExt?: boolean): string {
|
|
50
51
|
const imp = this.getFileImport(file)?.import ?? file;
|
|
51
|
-
return removeExt ? ManifestModuleUtil.
|
|
52
|
+
return removeExt ? ManifestModuleUtil.withoutSourceExtension(imp) : imp;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
/**
|
package/src/state.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
|
|
3
|
-
import { path, ManifestIndex
|
|
3
|
+
import { path, ManifestIndex } from '@travetto/manifest';
|
|
4
4
|
|
|
5
5
|
import { ManagedType, AnyType, ForeignType } from './resolver/types';
|
|
6
6
|
import { State, DecoratorMeta, Transformer, ModuleNameⲐ } from './types/visitor';
|
|
@@ -266,7 +266,7 @@ export class TransformerState implements State {
|
|
|
266
266
|
this.#modIdent = this.createIdentifier('ᚕm');
|
|
267
267
|
const entry = this.#resolver.getFileImport(this.source.fileName);
|
|
268
268
|
const decl = this.factory.createVariableDeclaration(this.#modIdent, undefined, undefined,
|
|
269
|
-
this.fromLiteral([entry?.module,
|
|
269
|
+
this.fromLiteral([entry?.module, entry?.relativeFile ?? ''])
|
|
270
270
|
);
|
|
271
271
|
this.addStatements([
|
|
272
272
|
this.factory.createVariableStatement([], this.factory.createVariableDeclarationList([decl]))
|