We want to use Rollup with Angular 4/Typescript and NPM We have the following requirement within our company:
What is the best way to achieve this using Typescript/Javascript/NPM/Rollup? We would use ES2015 syntax transpiled to commonJS syntax.
I don't think rollup has something similar to webpack dll plugin, so, my answer may appear unrelated but I think you could assume it as a good starting point and start looking for something similar in rollup.
a library living in a CDN:
DLL
with its corresponding DLL Reference
which exactly describes how to require the exported modules.https://cdn.mydomain.com/<libraryName>/<version>/<libraryName>.{js,json,d.ts}
(the requester should add ?<cacheBustingUID>
to avoid client caching issues). In addition to the normal versioning, I also suggest you to use a keyword latest
for the version
field, this to achieve an always true path
which points to the latest version of the bundle: (https://cdn.mydomain.com/foo/1.0.0/foo.{js,json,d.ts}
, and https://cdn.mydomain.com/foo/latest/foo.{js,json,d.ts}
).module.exports = env => {
const libs = ((name, version, exts) => (
exts.map(ext => `https://cdn.mydomain.com/${name}/${version}/${name}.${ext}`)
))('foo', 'latest', ['js', 'd.ts', 'json'])
return Promise
.all(libs.map(fetch))
.then([library, definitions, DLLReference] => {
// what to do?
// you can also inject the dynamic paths through `webpackDefinePlugin`
})
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With