-
Notifications
You must be signed in to change notification settings - Fork 122
build a consumable npm module #475
Comments
update: we used meta to trim it down. But now we are getting errors about the browser not being able to find our imports. it is 404-ing on them. Do you have an example we can peruse? |
Here is out build file ... it currently is 404-ing , but we figured out why. the output file contains registered modules named How do we get the systemjs-builder to do this for us? Here is our build file
|
Most likely you need to pass {normalize: true} option to builder.bundle(), as mentioned in the first item in 0.15.0 release notes here https://github.com/systemjs/builder/releases/tag/0.15.0 |
Thanks, tried that and no luck. We are trying to remove the |
And we want to control the prefix. Riffing on @johnpapa example code above, ... Suppose my desired module prefix is "xxx". Imagine a module file called
But we are getting
We can trick the builder by moving our source into an
Hacky but whatever. Still have the
So how do we control the generation of registered module names? |
You can have full control over normalized module names if you override But then you would need to override |
We finally "won" the game. The two essential tricks:
Step 1 gives us the module prefix we want (the We wrote gulp tasks to create the (unwanted) For the curious and future reference, this is the specific gulp task that runs the builder:
I"ll bet we could consolidate some of that configuration if we really knew what we were doing. Hope this helps others. |
@wardbell can you publish whole source for this somewhere? |
See my a2-in-memory-web-api repo. |
@wardbell paths configuration is exactly the system for controlling the output module names. I'm wondering if a |
@guybedford Thanks. I had forgotten that
|
@johnpapa thanks for clarifying. Yes the ability to ensure bundles contain no extension in the outputted names is not currently something that will currently continue to be supported in SystemJS with the planned deprecations but it will be a while yet before this happens. |
More specifically, we want to be able to do imports without extension specification such as Are you saying that you won;t support that at all or that we'll have to use an alternative means, such as some configuration of |
Those kinds of imports can work if the package uses a configuration - Bundles are now designed to allow configuration to be included with the bundle via: // ensure that angular is treated as a package,
// so that this config module is loaded before any module in angular
// I just noticed this technique won't work yet pending release of
// https://github.com/systemjs/systemjs/commit/32554417a73ce4440fd3d1d28f28612f2a6356ef
System.packageConfigPaths.push('angular/config.json');
System.registerDynamic('angular/config.json', [], false, function(require, exports, module) {
// package config here:
module.exports = {
defaultExtension: 'js'
};
});
System.register('angular/x.ext', [], function(_export) {
// ...
}); In this way the extension handling is always through the normalization layer, while the registration layer works completely in terms of file extensions. The power of the config build approach is that we then get all the flexibility of package configuration in a way that can be bundled up. |
Anyway, the point being that there are ways around this in the long term despite the extensions in the register being deprecated. |
nope, it gives (in my case):
while without |
@johnpapa @wardbell |
@valorkin |
If there is anything further I can do to help here please just let me know. |
I have a config almost identical to the one posted by @johnpapa above. When running the bundler, all I get is an empty file. If I remove the
|
Any ideas why it is generating an empty file with |
@SonofNun15 perhaps if you are using a wildcard expression in your bundle command, it is being affected by the paths? Eg perhaps |
Figured it out. The problem was that we were trying to pass |
Yes @guybedford, that exactly. Good guess! |
Guy - thanks for your help in the past. @wardbell and I are trying to create am npm package that will be consumable by others. It relies on angular2 and rxjs. We tried using the builder to make the file, but it was 684kb :)
Is there a simple example of how to get only what is needed?
The text was updated successfully, but these errors were encountered: