chadhietala / broccoli-rollup

Broccoli Plugin For Rollup
36 stars 23 forks source link

rollup-plugin-typescript Unexpected token #56

Open givanse opened 5 years ago

givanse commented 5 years ago

Adding rollup-plugin-typescript results on:

Unexpected token (Note that you need plugins to import files that are not JavaScript)
        at BroccoliRollup
-~- created here: -~-
    at new Plugin (/Users/gsilvae/code/broccoli-rollup-typescript/node_modules/broccoli-plugin/index.js:31:32)
    at new BroccoliRollup (/Users/gsilvae/code/broccoli-rollup-typescript/node_modules/broccoli-rollup/dist/index.js:15:9)
    at rollup (/Users/gsilvae/code/broccoli-rollup-typescript/node_modules/broccoli-rollup/dist/index.js:10:12)
    at Object.apply (/Users/gsilvae/code/broccoli-rollup-typescript/node_modules/broccoli-rollup/index.js:9:20)
    at default (/Users/gsilvae/code/broccoli-rollup-typescript/Brocfile.js:10:10)
    at getBuilder (/Users/gsilvae/code/broccoli-rollup-typescript/node_modules/broccoli/lib/cli.js:174:31)
    at Command.module.exports.program.command.alias.description.option.option.option.option.option.option.option.option.action (/Users/gsilvae/code/broccoli-rollup-typescript/node_modules/broccoli/lib/cli.js:123:23)
    at Command.listener (/Users/gsilvae/code/broccoli-rollup-typescript/node_modules/commander/index.js:315:8)
    at emitTwo (events.js:126:13)
    at Command.emit (events.js:214:7)
-~- (end) -~-

Running Rollup alone, with the same config, works fine.

Repo with test case: https://github.com/givanse/broccoli-rollup-typescript-test-case

givanse commented 5 years ago

Debugged a little and got to this line in Rollup https://github.com/rollup/rollup/blob/dd00ff5e480cacc368cc34dff7c2f1a3936d8d0f/src/ModuleLoader.ts#L353

In this location, the code has been pushed through the Rollup plugins but the code has not been transformed, code and originalCode are identical. So I guess that is why down the road we get the Unexpected token error.

Based on that, I would think this is a bug within rollup/broccoli-rollup-typescript. However, the error doesn't show up when broccoli-rollup is removed from the equation.