Repository navigation
Bundle Typescript without transpiling? #1395
Replies: 1 comment
|
If you mean the TypeScriptToLua compiler, you can keep the TypeScript files separate until that compiler processes them, and bundle its Lua output rather than producing a type-preserving {
"compilerOptions": {
"target": "ESNext",
"strict": true,
"rootDir": "src",
"outDir": "dist",
"noEmitOnError": true
},
"include": ["src/**/*.ts"],
"tstl": {
"luaTarget": "5.4",
"luaBundle": "bundle.lua",
"luaBundleEntry": "src/main.ts"
}
}Run // src/math.ts
export function double(value: number): number { return value * 2; }
// src/main.ts
import { double } from './math';
export const result: number = double(21);I checked this with The options are documented here. Rollup's normal TypeScript-plugin pipeline instead transforms the input into JavaScript for Rollup; it isn't a type-preserving TypeScript source bundler. Removing that transform is not sufficient either: a bare Rollup 3.7.5 build of the typed entry above fails parsing the type annotation. There is an important limit for the dependency part of your question: TypeScriptToLua's module documentation explicitly says it cannot import |
Uh oh!
There was an error while loading. Please reload this page.
I want to integrate rollup with TypescriptToLua which does not support JS imports yet, so I have to use a bundler to pack Typescript in.
However it uses Typescript types to do optimization and I wonder if that is possible for rollup to not transpile the Typescript, and instead just process the static ES modules import/export. Don't strip types.
For node_modules that have corresponding Typescript source, include them into the bundle as much as possible. That way we can ensure highest level of tstl compatibility
All reactions