diff --git a/docs/config-api.md b/docs/config-api.md index 4cc71db3..11727a7c 100644 --- a/docs/config-api.md +++ b/docs/config-api.md @@ -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 + +#### 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({ diff --git a/lib/core.js b/lib/core.js index a4fac2dd..6325f4b2 100644 --- a/lib/core.js +++ b/lib/core.js @@ -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); diff --git a/lib/package.js b/lib/package.js index a936ca44..60ede93a 100644 --- a/lib/package.js +++ b/lib/package.js @@ -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); diff --git a/lib/proto.js b/lib/proto.js index 7331887a..ae80b29a 100644 --- a/lib/proto.js +++ b/lib/proto.js @@ -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