rbxts-transform-boost 1.0.0 → 1.1.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.
@@ -1,34 +0,0 @@
1
- import type ts from "typescript";
2
- import { hasOptimizeDirective, hasStrictDirective } from "../util";
3
-
4
- export function nativePass(
5
- ts: typeof import("typescript"),
6
- ctx: ts.TransformationContext,
7
- sourceFile: ts.SourceFile,
8
- optimize: boolean,
9
- strict: boolean,
10
- ): ts.SourceFile {
11
- const factory = ctx.factory;
12
- const prepend: ts.Statement[] = [];
13
-
14
- if (strict && !hasStrictDirective(sourceFile)) {
15
- prepend.push(ts.addSyntheticLeadingComment(
16
- factory.createNotEmittedStatement(sourceFile),
17
- ts.SyntaxKind.SingleLineCommentTrivia,
18
- "!strict",
19
- true,
20
- ));
21
- }
22
-
23
- if (optimize && !hasOptimizeDirective(sourceFile)) {
24
- prepend.push(ts.addSyntheticLeadingComment(
25
- factory.createNotEmittedStatement(sourceFile),
26
- ts.SyntaxKind.SingleLineCommentTrivia,
27
- "!optimize 2",
28
- true,
29
- ));
30
- }
31
-
32
- if (prepend.length === 0) return sourceFile;
33
- return factory.updateSourceFile(sourceFile, [...prepend, ...Array.from(sourceFile.statements)]);
34
- }
package/src/util.ts DELETED
@@ -1,37 +0,0 @@
1
- import type ts from "typescript";
2
-
3
- export function hasOptimizeDirective(sourceFile: ts.SourceFile): boolean {
4
- return /^--!optimize\b/m.test(sourceFile.text) || /^\/\/!optimize\b/m.test(sourceFile.text);
5
- }
6
-
7
- export function hasStrictDirective(sourceFile: ts.SourceFile): boolean {
8
- return /^--!strict\b/m.test(sourceFile.text) || /^\/\/!strict\b/m.test(sourceFile.text);
9
- }
10
-
11
- export function chainKey(ts: typeof import("typescript"), node: ts.Expression): string | undefined {
12
- if (ts.isIdentifier(node)) return node.text;
13
- if (ts.isPropertyAccessExpression(node)) {
14
- const left = chainKey(ts, node.expression);
15
- if (left === undefined) return undefined;
16
- return `${left}.${node.name.text}`;
17
- }
18
- return undefined;
19
- }
20
-
21
- export function walk(ts: typeof import("typescript"), node: ts.Node, visitor: (n: ts.Node) => void): void {
22
- if (!node) return;
23
- visitor(node);
24
- ts.forEachChild(node, child => { if (child) walk(ts, child, visitor); });
25
- }
26
-
27
- export function isAssignmentTarget(ts: typeof import("typescript"), node: ts.Node): boolean {
28
- const parent = node.parent;
29
- if (!parent) return false;
30
- if (ts.isBinaryExpression(parent)) {
31
- return parent.left === node &&
32
- parent.operatorToken.kind === ts.SyntaxKind.EqualsToken;
33
- }
34
- if (ts.isPrefixUnaryExpression(parent) || ts.isPostfixUnaryExpression(parent)) return true;
35
- return false;
36
- }
37
-
package/tsconfig.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "commonjs",
5
- "moduleResolution": "node",
6
- "strict": true,
7
- "declaration": true,
8
- "outDir": "dist",
9
- "rootDir": "src",
10
- "esModuleInterop": true,
11
- "paths": { "typescript": ["./test/node_modules/typescript"] },
12
- "skipLibCheck": true,
13
- "types": ["node"]
14
- },
15
- "include": ["src"]
16
- }