Suggestion
π Search Terms
import ts without precompilation
β
Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Support for importing ts files at the package level.
π Motivating Example
Adding typescript entry points ts-module and ts-import to package.json
{
"version": "1.0.0",
"name": "@scope/foo",
"module": "dist/index.mjs",
"main": "dist/index.js",
"types": "types/index.d.ts",
"ts-module": "src/index.ts",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"ts-import": "./src/index.ts"
}
}
}
π» Use Cases
This will improve the developer experience. No need to compile files, work directly from source codes. The types folder with d.ts files is no longer needed during custom code development.
When developing packages in the workspace, for example: @scope/foo, @scope/bar. (each package is compiled separately)
@scope/bar depends on @scope/foo.
index.ts in @scope/bar:
import { MyInterface } from '@scope/foo'; // !!!< scope/foo must be pre-compiled
Now, in order for this to work without compilation, and the import went straight from the source codes, you need to add the following construction to tsconfig.json:
"paths": {
"@scope/foo": ["./foo/src/index"]
}
This approach has a problem after compiling @scope/bar with d.ts files.
d.ts files appear in DeclarationDir that are needed for another package (@scope/foo)
Suggestion
π Search Terms
import ts without precompilation
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Support for importing ts files at the package level.
π Motivating Example
Adding typescript entry points
ts-moduleandts-importto package.json{ "version": "1.0.0", "name": "@scope/foo", "module": "dist/index.mjs", "main": "dist/index.js", "types": "types/index.d.ts", "ts-module": "src/index.ts", "exports": { ".": { "import": "./dist/index.mjs", "require": "./dist/index.js", "ts-import": "./src/index.ts" } } }π» Use Cases
This will improve the developer experience. No need to compile files, work directly from source codes. The types folder with d.ts files is no longer needed during custom code development.
When developing packages in the workspace, for example: @scope/foo, @scope/bar. (each package is compiled separately)
@scope/bar depends on @scope/foo.
index.ts in @scope/bar:
Now, in order for this to work without compilation, and the import went straight from the source codes, you need to add the following construction to tsconfig.json:
This approach has a problem after compiling @scope/bar with d.ts files.
d.ts files appear in DeclarationDir that are needed for another package (@scope/foo)