RupertJS / stassets

Static Asset Compiling Express Middleware
ISC License
2 stars 2 forks source link

Traceur for es6 files. #4

Closed DavidSouther closed 2 years ago

DavidSouther commented 10 years ago

Initial approach built out. Probably won't be in stassets, but in rupert-config-esnext.

jamiebuilds commented 9 years ago

Hey @DavidSouther, while Traceur is a great option, you might also want to check out 6to5. We even have a connect plugin already. I'm a contributor to 6to5 so if you need any help let me know or join our gitter room.

DavidSouther commented 9 years ago

@thejameskyle Does 6to5 also handle TypeScript and AtScript (typing / annotations)?

DavidSouther commented 9 years ago

NB: Actual implementation in https://github.com/RupertJS/rupert-config-esnext

jamiebuilds commented 9 years ago

Types are currently in the works which you can track here: https://github.com/6to5/6to5/issues/260

Looking at your config it looks like you had to do some magic to get the sourcemaps support you wanted. 6to5 has much better support for sourcemaps (inline or external). Also, check out our Grunt plugin: https://github.com/sindresorhus/grunt-6to5.

DavidSouther commented 9 years ago

Awesome, I'll keep an eye on those.

From a Rupert standpoint, best would be for you to make a rupert-config-6to5 :+1:

You'll need to attach a function to require('rupert/node_modules/stassets/lib/Watchers/Script').renderers with key ts, signature function(code:string, path:string), where code is the entire source string of a single file, and path is the absolute string path to the file. It must return a promise-like that resolves to {content: string, sourceMap: Object, path: string} where content is the valid JS5 source, sourceMap is a Javascript Object that is a valid SourceMap version 3 (highly recommended to embed sourcesContent, or the content will get lost in concatenation), and path is the effective path of the project.

Two useful helpers are this.moduleName, which creates a sane dot-separated module name relative to the root of the project as specified in config.stassets.prefix, and this.pathpart, which does the same to create a relative filepath.