UNPKG

ng-router-loader

Version:

Webpack loader for `NgModule` lazy loading using the angular router

1 lines 6.78 kB
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":";AAyLa,QAAA,eAAe,GAAwB;IAClD,SAAS,EAAE,GAAG;IACd,GAAG,EAAE,KAAK;IACV,YAAY,EAAE,YAAY;IAC1B,aAAa,EAAE,WAAW;IAC1B,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,IAAI;CACf,CAAC;AAEW,QAAA,wBAAwB,GAAyB;IAC5D,MAAM,EAAE,SAAS;IACjB,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,SAAS;CACpB,CAAC","sourcesContent":["export type BUILT_IN_LOADERS = 'sync' | 'async-require' | 'async-system';\n\n/**\n * Loader options for the `ng-router-loader`.\n *\n * ## Resource specific options\n * Some options apply to a resource, the global option serve as the default but can be overridden in a resource URI using query parameters.\n *\n * >Resource specific options are marked with the **resource_override** tag.\n *\n * #### AOT mode\n * Some of the options apply on when the `aot` flag is set to **true**.\n *\n * >AOT specific options are marked with the **aot_mode** tag.\n *\n *\n * ## Usage\n * #### Webpack 1\n * ```ts\n * {\n * test: /\\.ts$/,\n * loaders: [\n * 'awesome-typescript-loader',\n * 'ng-router-loader?aot=true&genDir=codegen'\n * ]\n * }\n * ```\n *\n * #### Webpack 2\n * You can use the query string as well as:\n * ```ts\n * {\n * test: /\\.ts$/,\n * use: [\n * 'awesome-typescript-loader',\n * {\n * loader: 'ng-router-loader',\n * options: {\n * aot: true,\n * genDir: 'codegen'\n * }\n * }\n * ]\n * }\n * ```\n */\nexport interface RouterLoaderOptions {\n /**\n * A separator used to identify the NgModule class name in the URI.\n * @default '#'\n */\n delimiter?: string;\n\n /**\n * Enable support for AOT compiled code.\n * If you are bundling AOT compiled code (.ngfactory) set this to true\n * @default false\n */\n aot?: boolean;\n\n /**\n * The suffix used by the angular compiler to mark compiled version of source tree modules.\n *\n * @aot_mode\n * @default '.ngfactory'\n */\n moduleSuffix?: string;\n\n /**\n * The suffix used by the angular compiler to mark compiled version of source tree NgModule class.\n *\n * @aot_mode\n * @default 'NgFactory'\n */\n factorySuffix?: string;\n\n /**\n * The code generator to use when replacing the URI with a callback.\n *\n * There are 3 built in code generators:\n * - sync: The module will be part of the bundle (lazy initializing but NOT lazy loading)\n * - async-require: The module will load in a separate bundle, using webpack's `require.ensure` feature (support chunkName)\n * - async-system: The module will load in a separate bundle using System.import\n *\n * Note: System.import is deprecated in Webpack 2, will be removed in webpack 3 (https://github.com/webpack/webpack/releases/tag/v2.1.0-beta.28)\n *\n * You can override the loader in a specific resource by setting the loader in a resource query.\n *\n * @resource_override\n * @default 'async-require'\n */\n loader?: BUILT_IN_LOADERS | string;\n\n /**\n * The destination of compiled files created by the angular compiler-cli.\n * The directory is resolved relative to the current working directory (process.cwd())\n *\n * When genDir is empty or \".\" the destination is the project root and factory files are saved along side the source tree.\n *\n * IMPORTANT NOTE:\n * The compiler-cli takes this value from the tsconfig file @ \"angularCompilerOptions.genDir\" and\n * resolve the destination with \"genDir\" relative to the \"tsconfig\" file.\n * Webpack (hence the loader) run on a different process so it does not know about that \"tsconfig\".\n * If your setup is complex you need to make sure that the 2 \"genDir\"s resolve to the same directory according to the logic described here.\n *\n * The best scenario is when \"tsconfig.json\" is in the project root and webpack is executed from the project root.\n * In this case the \"genDir\" should be identical to the \"genDir\" value in \"tsconfig.json\"\n *\n * @aot_mode\n * @default ''\n */\n genDir?: string;\n\n /**\n * If false outputs a pretty code\n *\n * @default true\n */\n inline?: boolean;\n\n debug?: boolean;\n\n /**\n * Resolve ngfactory modules and verify they exist, if not track the symbol and search for the ngfactory\n * that exports the symbol.\n *\n * AOT compilation emit ngfactory files only for NgModule, Component and Directive.\n * If a module does not have one of those the compiler will not create an ngfactory file for it.\n *\n * In webpack it is a common practice to use directories as packages (barrel pattern) having an\n * index file exporting what's needed.\n *\n * When a URI reference a module (ModA) that:\n * - export an NgModule defined in an other module (ModB) and;\n * - ModA has no NgModule, Component or Directive defined inside it\n *\n * The resolved file will \"ModA.ngfactory\", even though it does not exists.\n * When bySymbol is true the loader will use the metadata in \"ngsummary.json\" files to lookup the\n * first ngfactory file that exports ModB, it will then use it as the resolved URI.\n *\n * You can override this option in a specific resource by setting the bySymbol property in a resource query.\n *\n * @resource_override\n * @aot_mode\n * @default true\n */\n bySymbol?: boolean;\n\n}\n\n/**\n * Resource specific options, defined as query string on the resource URI.\n *\n * ```\n * {\n * path: 'home',\n * loadChildren: './app/home/home-module#HomeModule?loader=sync&bySymbol=false'\n * }\n * ```\n */\nexport interface RouteResourceOptions {\n /**\n * The code generator to use when replacing the URI with a callback.\n *\n * @resource_override RouterLoaderOptions.loader\n */\n loader?: BUILT_IN_LOADERS | string;\n\n /**\n * A chunk name used by webpack to bundle async modules.\n * Used by the \"async-require\" loader.\n *\n * For more information see [webpack require.ensure](https://webpack.js.org/guides/code-splitting/#code-splitting-with-require-ensure-)\n */\n chunkName?: string;\n\n /**\n * Resolve ngfactory modules and verify they exist, if not track the symbol and search for the ngfactory\n * that exports the symbol.\n *\n * @resource_override RouterLoaderOptions.loader\n */\n bySymbol?: boolean;\n}\n\nexport const DEFAULT_OPTIONS: RouterLoaderOptions = {\n delimiter: '#',\n aot: false,\n moduleSuffix: '.ngfactory',\n factorySuffix: 'NgFactory',\n loader: 'async-require',\n genDir: '',\n inline: true,\n bySymbol: true\n};\n\nexport const DEFAULT_RESOURCE_OPTIONS: RouteResourceOptions = {\n loader: undefined,\n chunkName: undefined,\n bySymbol: undefined\n};\n\n"]}