Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS paths not being replaced #50

Open
r1zyn opened this issue Jan 20, 2023 · 0 comments
Open

JS paths not being replaced #50

r1zyn opened this issue Jan 20, 2023 · 0 comments

Comments

@r1zyn
Copy link

r1zyn commented Jan 20, 2023

Same as #4

tsconfig.json

{
	"compilerOptions": {
		"incremental": true, // Enable incremental compilation
		"composite": false, // Enable constraints that allow a TypeScript project to be used with project references. (enable for declaration files)
		"tsBuildInfoFile": "logs/.tsbuildinfo", // Specify the folder for .tsbuildinfo incremental compilation files.
		"target": "es6", // Set the JavaScript language version for emitted JavaScript and include compatible library declarations.
		"lib": [ // Specify a set of bundled library declaration files that describe the target runtime environment.
			"ESNext",
			"ESNext.Array",
			"ESNext.AsyncIterable",
			"ESNext.Intl",
			"ESNext.Symbol"
		],
		"experimentalDecorators": true, // Enable experimental support for TC39 stage 2 draft decorators.
		"emitDecoratorMetadata": true, // Emit design-type metadata for decorated declarations in source files.
		"module": "CommonJS", // Specify what module code is generated.
		"rootDir": "src", // Specify the root folder within your source files.
		"moduleResolution": "node", // Specify how TypeScript looks up a file from a given module specifier.
		"baseUrl": ".", // Specify the base directory to resolve non-relative module names.
		"paths": {
			"@lib/*": [
				"./src/lib/*"
			],
			"@scripts/*": [
				"./src/scripts/*"
			],
			"@typings/*": [
				"./src/typings/*"
			],
			"@core/*": [
				"./src/*"
			],
			"@commands/*": [
				"./src/commands/*"
			],
			"@subcommands/*": [
				"./src/commands/subcommands/*"
			],
			"@listeners/*": [
				"./src/listeners"
			]
		}, // A series of entries which re-map imports to lookup locations relative to the baseUrl.
		"typeRoots": [ // Specify multiple folders that act like ./node_modules/@types.
			"node_modules/@types"
		],
		"allowUmdGlobalAccess": true, // Allow accessing UMD globals from modules.
		"resolveJsonModule": true, // Enable importing .json files
		"noResolve": false, // Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project.
		"allowJs": false, // Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files.
		"checkJs": false, // Enable error reporting in type-checked JavaScript files.
		"declaration": false, // Generate .d.ts files from TypeScript and JavaScript files in your project.
		"declarationMap": false, // Create sourcemaps for d.ts files.
		"emitDeclarationOnly": false, // Only output d.ts files and not JavaScript files.
		"sourceMap": false, // Create source map files for emitted JavaScript files.
		"outDir": "build", // Specify an output folder for all emitted files.
		"esModuleInterop": true, // Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility.
		"forceConsistentCasingInFileNames": true, // Ensure that casing is correct in imports.
		"strict": true, // Enable all strict type-checking options.
		"noImplicitAny": false, // Enable error reporting for expressions and declarations with an implied `any` type.
		"strictNullChecks": true, // When type checking, take into account `null` and `undefined`.
		"strictFunctionTypes": true, // When assigning functions, check to ensure parameters and the return values are subtype-compatible.
		"strictBindCallApply": true, // Check that the arguments for `bind`, `call`, and `apply` methods match the original function.
		"strictPropertyInitialization": false, // Check for class properties that are declared but not set in the constructor.
		"noImplicitThis": true, // Enable error reporting when `this` is given the type `any`.
		"useUnknownInCatchVariables": false, // Type catch clause variables as 'unknown' instead of 'any'.
		"alwaysStrict": true, // Ensure 'use strict' is always emitted.
		"allowUnusedLabels": true, // Disable error reporting for unused labels.
		"allowUnreachableCode": false, // Disable error reporting for unreachable code.
		"skipLibCheck": true // Skip type checking all .d.ts files.
	},
	"include": [
		"src"
	],
	"exclude": [
		"build",
		"node_modules",
		"**/*.js"
	]
}

Project folder structure
image

src/index.ts imports

import { AstraniumClient } from "@lib/Client";
import type { Guild } from "discord.js";
import { Logger } from "@lib/Logger";
import { PrismaClient } from "@prisma/client";

build/index.js imports

const Client_1 = require("@lib/Client");
const Logger_1 = require("@lib/Logger");
const client_1 = require("@prisma/client");

Running npx tspath -f and getting the following:

TSPath v2.6.8
Try: 'tspath --help' for more information
Parsing project: astranium C:\Users\ascen\OneDrive\Documents\Programming\Bots\Astranium\
Indexing files...
Total files processed: 50
Total paths processed: 77
Operation finished in: 537.403ms
Project is prepared, now run it normally!

Node version: v17.2.0
TypeScript version: v4.8.4
tspath version: v2.6.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant