typescript-bundle icon indicating copy to clipboard operation
typescript-bundle copied to clipboard

Cannot process correctly single file project

Open codehz opened this issue 6 years ago • 1 comments
trafficstars

I expected it can handle both multi-file project and single-file project, (tsc will not emit the "define" when there are only one source)

Or just rollback to use tsc when detect there only one source.

Use Case: Project Template, started from only one source file.

codehz avatar Mar 07 '19 03:03 codehz

Hi,

This tool does support single and multiple file bundling. However, the AMD loader is written in either case. Are you suggesting that the AMD loader should be omitted when compiling with a single source file?

It would be possible to implement this, the AMD loader gets written in here, where the code argument is typescript compiler output + any assets defines added from the previous transform stage. There is also a AMDReader type here that could be used to test the bundle for the presence of define (avoiding the need to regex and perhaps allowing for a more informed decision to be made with respect to conditional AMD loader emit).

Open to thoughts, if you think this is valuable enough, can potentially look at implementing it. I am also open to PR's on this project. So if its something you would like to take a look at, id be happy to help with it.

sinclairzx81 avatar Mar 07 '19 09:03 sinclairzx81