rename package meta to modules #816

This commit is contained in:
guybedford 2015-10-08 14:28:28 +02:00
parent 3790f5d862
commit 175cae9ce7
4 changed files with 31 additions and 14 deletions

View File

@ -25,7 +25,7 @@ For this reason it is usually advisable to use `System.config` instead of settin
* [defaultJSExtensions](#defaultjsextensions)
* [depCache](#depcache)
* [map](#map)
* [meta](#meta)
* [modules](#modules)
* [packages](#packages)
* [paths](#paths)
* [traceurOptions](#traceuroptions)
@ -140,13 +140,16 @@ System.import('package/path.js');
> Note map configuration used to support contextual submaps but this has been deprecated for package configuration.
#### meta
<a name="meta">
#### modules
Type: `Object`
Default: `{}`
Module meta provides an API for SystemJS to understand how to load modules correctly.
_Previously called **meta**_
Meta is how we set the module format of a module, or know how to shim dependencies of a global script.
Package modules provides a meta API for SystemJS to understand how to load modules correctly.
The module meta is how we set the module format of a module, or know how to shim dependencies of a global script.
```javascript
System.config({

View File

@ -257,7 +257,15 @@ SystemJSLoader.prototype.config = function(cfg) {
if (!this.packages[prop] && this.defaultJSExtensions && p.substr(p.length - 3, 3) != '.js')
prop = prop.substr(0, prop.length - 3);
this.packages[prop]= this.packages[prop] || {};
this.packages[prop] = this.packages[prop] || {};
// meta backwards compatibility
if (cfg.packages[p].meta) {
warn.call(this, 'Package ' + p + ' is configured with meta, which is deprecated as it has been renamed to modules.');
cfg.packages[p].modules = cfg.packages[p].meta;
delete cfg.packages[p].meta;
}
for (var q in cfg.packages[p])
if (indexOf.call(packageProperties, q) == -1)
warn.call(this, '"' + q + '" is not a valid package configuration option in package ' + p);

View File

@ -9,7 +9,7 @@
* main: 'index.js', // when not set, package name is requested directly
* format: 'amd',
* defaultExtension: 'ts', // defaults to 'js', can be set to false
* meta: {
* modules: {
* '*.ts': {
* loader: 'typescript'
* },
@ -51,12 +51,12 @@
* - map and defaultExtension are applied to the main
* - defaultExtension adds the extension only if no other extension is present
* - defaultJSExtensions applies after map when defaultExtension is not set
* - if a meta value is available for a module, map and defaultExtension are skipped
* - if a modules value is available for a module, map and defaultExtension are skipped
* - like global map, package map also applies to subpaths (sizzle/x, ./vendor/another/sub)
* - condition module map is '@env' module in package or '@system-env' globally
*
* In addition, the following meta properties will be allowed to be package
* -relative as well in the package meta config:
* In addition, the following modules properties will be allowed to be package
* -relative as well in the package module config:
*
* - loader
* - alias
@ -156,8 +156,8 @@
var skipExtension = !!(isPlugin || subPath.indexOf('#?') != -1 || subPath.match(interpolationRegEx));
// exact meta or meta with any content after the last wildcard skips extension
if (!skipExtension && pkg.meta)
getMetaMatches(pkg.meta, pkgName, subPath, function(metaPattern, matchMeta, matchDepth) {
if (!skipExtension && pkg.modules)
getMetaMatches(pkg.modules, pkgName, subPath, function(metaPattern, matchMeta, matchDepth) {
if (matchDepth == 0 || metaPattern.lastIndexOf('*') != metaPattern.length - 1)
skipExtension = true;
});
@ -416,6 +416,12 @@
if (cfg.systemjs)
cfg = cfg.systemjs;
// meta backwards compatibility
if (cfg.meta) {
cfg.modules = cfg.meta;
warn.call(loader, 'Package config file ' + pkgConfigPath + ' is configured with meta, which is deprecated as it has been renamed to modules.');
}
// remove any non-system properties if generic config file (eg package.json)
for (var p in cfg) {
if (indexOf.call(packageProperties, p) == -1)
@ -512,9 +518,9 @@
}
var meta = {};
if (pkg.meta) {
if (pkg.modules) {
var bestDepth = 0;
getMetaMatches(pkg.meta, pkgName, subPath, function(metaPattern, matchMeta, matchDepth) {
getMetaMatches(pkg.modules, pkgName, subPath, function(metaPattern, matchMeta, matchDepth) {
if (matchDepth > bestDepth)
bestDepth = matchDepth;
extendMeta(meta, matchMeta, matchDepth && bestDepth > matchDepth);

View File

@ -88,7 +88,7 @@ function extend(a, b, prepend) {
}
// package configuration options
var packageProperties = ['main', 'format', 'defaultExtension', 'meta', 'map', 'basePath', 'depCache'];
var packageProperties = ['main', 'format', 'defaultExtension', 'modules', 'map', 'basePath', 'depCache'];
// meta first-level extends where:
// array + array appends