Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ngtools/webpack

Package Overview
Dependencies
Maintainers
2
Versions
843
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ngtools/webpack - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

13

package.json
{
"name": "@ngtools/webpack",
"version": "1.1.4",
"description": "",
"version": "1.1.5",
"description": "Webpack plugin that AoT compiles your Angular components and modules.",
"main": "./src/index.js",
"typings": "src/index.d.ts",
"license": "MIT",
"keywords": [
"angular",
"webpack",
"plugin",
"aot"
],
"repository": {

@@ -11,3 +19,2 @@ "type": "git",

"author": "angular",
"license": "MIT",
"bugs": {

@@ -14,0 +21,0 @@ "url": "https://github.com/angular/angular-cli/issues"

@@ -121,3 +121,3 @@ "use strict";

var cb_1 = this.async();
plugin.done
Promise.resolve()
.then(function () { return _removeDecorators(_this.resource, source); })

@@ -124,0 +124,0 @@ .then(function (sourceText) { return _replaceBootstrap(_this.resource, sourceText, plugin); })

@@ -9,6 +9,13 @@ import * as ts from 'typescript';

entryModule?: string;
genDir?: string;
mainPath?: string;
typeChecking?: boolean;
}
export interface LazyRoute {
moduleRoute: ModuleRoute;
moduleRelativePath: string;
moduleAbsolutePath: string;
}
export interface LazyRouteMap {
[path: string]: LazyRoute;
}
export declare class ModuleRoute {

@@ -36,2 +43,4 @@ readonly path: string;

private _typeCheck;
private _basePath;
private _genDir;
constructor(options: AotPluginOptions);

@@ -49,3 +58,3 @@ readonly basePath: string;

private _make(compilation, cb);
private _resolveModule(module, containingFile);
private _resolveModulePath(module, containingFile);
private _processNgModule(module, containingFile);

@@ -52,0 +61,0 @@ private getNgModuleMetadata(staticSymbol);

@@ -13,2 +13,3 @@ "use strict";

var entry_resolver_1 = require('./entry_resolver');
var compiler_cli_1 = require('@angular/compiler-cli');
var ModuleRoute = (function () {

@@ -38,3 +39,3 @@ function ModuleRoute(path, className) {

Object.defineProperty(AotPlugin.prototype, "basePath", {
get: function () { return this._angularCompilerOptions.basePath; },
get: function () { return this._basePath; },
enumerable: true,

@@ -64,3 +65,3 @@ configurable: true

Object.defineProperty(AotPlugin.prototype, "genDir", {
get: function () { return this._angularCompilerOptions.genDir; },
get: function () { return this._genDir; },
enumerable: true,

@@ -96,6 +97,3 @@ configurable: true

var genDir = basePath;
if (options.hasOwnProperty('genDir')) {
genDir = options.genDir;
}
else if (tsConfig.ngOptions.hasOwnProperty('genDir')) {
if (tsConfig.ngOptions.hasOwnProperty('genDir')) {
genDir = tsConfig.ngOptions.genDir;

@@ -120,2 +118,4 @@ }

});
this._basePath = basePath;
this._genDir = genDir;
if (options.hasOwnProperty('typeChecking')) {

@@ -165,5 +165,6 @@ this._typeCheck = options.typeChecking;

compiler.resolvers.normal.plugin('resolve', function (request, cb) {
// Populate the file system cache with the virtual module.
_this._compilerHost.populateWebpackResolver(compiler.resolvers.normal);
if (cb) {
if (request.request.match(/\.ts$/)) {
_this.done.then(function () { return cb(); });
}
else {
cb();

@@ -210,14 +211,18 @@ }

.then(function () {
// Populate the file system cache with the virtual module.
_this._compilerHost.populateWebpackResolver(_this._compiler.resolvers.normal);
})
.then(function () {
// Process the lazy routes
_this._lazyRoutes =
_this._processNgModule(_this._entryModule, null)
.map(function (module) { return ModuleRoute.fromString(module); })
.reduce(function (lazyRoutes, module) {
lazyRoutes[(module.path + ".ngfactory")] = path.join(_this.genDir, module.path + '.ngfactory.ts');
return lazyRoutes;
}, {});
_this._lazyRoutes = {};
var allLazyRoutes = _this._processNgModule(_this._entryModule, null);
Object.keys(allLazyRoutes)
.forEach(function (k) {
var lazyRoute = allLazyRoutes[k];
_this._lazyRoutes[k + '.ngfactory'] = lazyRoute.moduleAbsolutePath + '.ngfactory.ts';
});
})
.then(function () { return cb(); }, function (err) { return cb(err); });
.then(function () { return cb(); }, function (err) { cb(err); });
};
AotPlugin.prototype._resolveModule = function (module, containingFile) {
AotPlugin.prototype._resolveModulePath = function (module, containingFile) {
if (module.path.startsWith('.')) {

@@ -234,18 +239,57 @@ return path.join(path.dirname(containingFile), module.path);

}
var resolvedModulePath = this._resolveModule(module, containingFile);
var relativeModulePath = this._resolveModulePath(module, containingFile);
var staticSymbol = this._reflectorHost
.findDeclaration(modulePath, module.className, containingFile);
var entryNgModuleMetadata = this.getNgModuleMetadata(staticSymbol);
var loadChildren = this.extractLoadChildren(entryNgModuleMetadata);
var result = loadChildren.map(function (route) {
return _this._resolveModule(new ModuleRoute(route), resolvedModulePath);
var loadChildrenRoute = this.extractLoadChildren(entryNgModuleMetadata)
.map(function (route) {
var mr = ModuleRoute.fromString(route);
var relativePath = _this._resolveModulePath(mr, relativeModulePath);
var absolutePath = path.join(_this.genDir, relativePath);
return {
moduleRoute: mr,
moduleRelativePath: relativePath,
moduleAbsolutePath: absolutePath
};
});
var resultMap = loadChildrenRoute
.reduce(function (acc, curr) {
var key = curr.moduleRoute.path;
if (acc[key]) {
if (acc[key].moduleAbsolutePath != curr.moduleAbsolutePath) {
throw new Error(("Duplicated path in loadChildren detected: \"" + key + "\" is used in 2 ") +
'loadChildren, but they point to different modules. Webpack cannot distinguish ' +
'between the two based on context and would fail to load the proper one.');
}
}
else {
acc[key] = curr;
}
return acc;
}, {});
// Also concatenate every child of child modules.
for (var _i = 0, loadChildren_1 = loadChildren; _i < loadChildren_1.length; _i++) {
var route = loadChildren_1[_i];
var childModule = ModuleRoute.fromString(route);
var children = this._processNgModule(childModule, resolvedModulePath + '.ts');
result.push.apply(result, children);
var _loop_1 = function(lazyRoute) {
var mr = lazyRoute.moduleRoute;
var children = this_1._processNgModule(mr, relativeModulePath);
Object.keys(children).forEach(function (p) {
var child = children[p];
var key = child.moduleRoute.path;
if (resultMap[key]) {
if (resultMap[key].moduleAbsolutePath != child.moduleAbsolutePath) {
throw new Error(("Duplicated path in loadChildren detected: \"" + key + "\" is used in 2 ") +
'loadChildren, but they point to different modules. Webpack cannot distinguish ' +
'between the two based on context and would fail to load the proper one.');
}
}
else {
resultMap[key] = child;
}
});
};
var this_1 = this;
for (var _i = 0, loadChildrenRoute_1 = loadChildrenRoute; _i < loadChildrenRoute_1.length; _i++) {
var lazyRoute = loadChildrenRoute_1[_i];
_loop_1(lazyRoute);
}
return result;
return resultMap;
};

@@ -261,6 +305,18 @@ AotPlugin.prototype.getNgModuleMetadata = function (staticSymbol) {

var _this = this;
var routes = ngModuleDecorator.imports.reduce(function (mem, m) {
var routes = (ngModuleDecorator.imports || []).reduce(function (mem, m) {
return mem.concat(_this.collectRoutes(m.providers));
}, this.collectRoutes(ngModuleDecorator.providers));
return this.collectLoadChildren(routes);
return this.collectLoadChildren(routes)
.concat((ngModuleDecorator.imports || [])
.map(function (staticSymbol) {
if (staticSymbol instanceof compiler_cli_1.StaticSymbol) {
var entryNgModuleMetadata = _this.getNgModuleMetadata(staticSymbol);
return _this.extractLoadChildren(entryNgModuleMetadata);
}
else {
return [];
}
})
.reduce(function (acc, i) { return acc.concat(i); }, []))
.filter(function (x) { return !!x; });
};

@@ -267,0 +323,0 @@ AotPlugin.prototype.collectRoutes = function (providers) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc