Closed dazinator closed 6 years ago
To configure rollup-plugin-amd
and module-lookup-amd
, instead of this:
options.AddImport((a) =>
{
a.RequiresNpmModule("module-lookup-amd", "5.0.1")
.HasDefaultExportName("lookup"); // only imported into the script as default export name, won't be included in rollupjs plugins list, but other plugin config could reference it.
})
.AddPlugin((a) =>
{
a.RequiresNpmModule("rollup-plugin-amd", "3.0.0")
.HasOptionsOfKind(OptionsKind.Object, (amdPluginOptions) =>
{
amdPluginOptions.rewire = "FUNCfunction (moduleId, parentPath) { return lookup({ partial: moduleId, filename: parentPath, config: {baseUrl: '/amd'} }); }FUNC";
});
});
You can now do this:
options
.ImportModuleLookupAmd()
.AddPluginAmd((amdPluginOptions) =>
{
amdPluginOptions.RewireFunction("function (moduleId, parentPath) { return lookup({ partial: moduleId, filename: parentPath, config: {baseUrl: '/amd'} }); }");
})
I provide a fluent API for importing modules, and adding rollup plugins to the rollup build script. However this fluent API is for the general case, i.e adding any version of any plugin, and then configuring its options based on
dynamic
. You have to know what options to set for each plugin and its down to you to set them correctly.I am going to add some extension methods to the fluent configuration of rollup, for specific plugins that I have found useful. I expect this will grow over time.
Starting with:
This should pave the way for more in future.