New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular-router-loader

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-router-loader - npm Package Compare versions

Comparing version

to
0.6.0

11

docs/options.md

@@ -63,10 +63,13 @@ ## General Loader Options

In your `tsconfig.json`, if you set the `genDir` in the `angularCompilerOptions` to compile to a separate directory, this option needs to be set to the relative path to your application directory.
In your `tsconfig.json`, if you set the `genDir` in the `angularCompilerOptions` to compile to a separate directory, this option needs to be set to the same value here.
## AoT example
Example file structure
Example file structure (after an AOT build)
```
|-- src
|-- app
|-- compiled
|-- src
|-- app
|-- src
|-- app
|-- tsconfig.json

@@ -73,0 +76,0 @@ ```

{
"name": "angular-router-loader",
"version": "0.5.0",
"version": "0.6.0",
"description": "A webpack loader for Angular that enables string-based module loading with the Angular Router",

@@ -21,3 +21,3 @@ "main": "src/index.js",

"dependencies": {
"loader-utils": "^0.2.15"
"loader-utils": "^1.0.2"
},

@@ -24,0 +24,0 @@ "bugs": {

@@ -42,2 +42,7 @@ # angular-router-loader

**NOTE**: When specifying a relative path to lazy loaded module, one of the following two conditions *must* hold:
* The routes are defined in the same module file where it is imported with `RouterModule.forRoot` or `RouterModule.forChild`
* The routes are defined in a separate routing file, and that routing file is a sibling of module file.
## Synchronous Loading

@@ -44,0 +49,0 @@

@@ -99,2 +99,19 @@ var should = require('should');

it('should return a plain javascript loadChildren async require statement', function() {
var result = [
'loadChildren: () => new Promise(function (resolve) {',
' require.ensure([], function (require) {',
' resolve(require(\'./path/to/file.module\')[\'FileModule\']);',
' });',
'})'
];
var loadedString = loader.call({
resourcePath: resourcePath.replace('.ts', '.js'),
query: query
}, `loadChildren: '${modulePath}'`);
checkResult(loadedString, result);
});
it('should return a loadChildren sync require statement', function() {

@@ -101,0 +118,0 @@ var result = [

@@ -55,2 +55,13 @@ var should = require('should');

it('should return an asynchronous require loadChildren statement with vanilla javascript', function() {
var result = [
'loadChildren: () => new Promise(function (resolve) {',
' require.ensure([], function (require) {',
' resolve(' + getRequireString(path, name) + ');',
' }, \'name\');',
'})'
];
getRequireLoader('path', 'name', 'name', true, true).should.eql(result.join(''));
});
});

@@ -57,0 +68,0 @@

@@ -12,3 +12,3 @@ var loaderUtils = require('loader-utils');

// parse query params
var query = loaderUtils.parseQuery(this.query);
var query = loaderUtils.getOptions(this) || {};

@@ -29,2 +29,3 @@ // get query options

var filename = utils.getFilename(resourcePath);
var isJs = path.extname(resourcePath).toLowerCase() === '.js';

@@ -35,3 +36,3 @@ var replacedSource = source.replace(loadChildrenRegex, function(match, loadString) {

var hasQuery = queryIndex !== -1;
var loadStringQuery = hasQuery ? loaderUtils.parseQuery(loadString.substr(queryIndex)) : {};
var loadStringQuery = hasQuery ? loaderUtils.getOptions({ query: loadString.substr(queryIndex) }) : {};
var sync = !!loadStringQuery.sync;

@@ -96,3 +97,3 @@ var chunkName = loadStringQuery.chunkName || undefined;

} else {
replacement = utils.getRequireLoader(filePath, chunkName, moduleName, inline);
replacement = utils.getRequireLoader(filePath, chunkName, moduleName, inline, isJs);
}

@@ -99,0 +100,0 @@

@@ -20,3 +20,3 @@ var os = require('os');

module.exports.getRequireLoader = function(filePath, chunkName, moduleName, inline) {
module.exports.getRequireLoader = function(filePath, chunkName, moduleName, inline, isJs) {
var requireString = module.exports.getRequireString(filePath, moduleName);

@@ -27,3 +27,3 @@ var webpackChunkName = chunkName ? ', \'' + chunkName + '\'' : '';

'loadChildren: () => new Promise(function (resolve) {',
' (require as any).ensure([], function (require: any) {',
' ' + (isJs ? 'require' : '(require as any)') + '.ensure([], function (' + (isJs ? 'require' : 'require: any') + ') {',
' resolve(' + requireString + ');',

@@ -30,0 +30,0 @@ ' }' + webpackChunkName + ');',