angular-rollup
Advanced tools
Changelog
1.0.0-rc.3
ngr generate module
Changelog
1.0.0-rc.2
system.config.js
that prevented rxjs from being currently mapped in dev modengr update --lib
. This argument will be deprecated in a future release, Use ngr generate lib
instead.Generate the configuration required for library packages with ngr generate lib
or use ngr generate wizard
.
ngr generate lib --name my-lib --dir src/app/shared/lib
After you have generated some components for the library, use ngr build lib
to build the library in the dist
folder.
ngr build lib -c src/app/shared/lib/lib.config.json
Generate a unit test either use the wizard (ngr generate wizard
) or use the following examples as a guide.
ngr generate unit --dir src/app/shared/components/my-component --name my-component
Optionally, generate a unit test for a directive with the --spec argument.
ngr generate unit --dir src/app/shared/components/my-component --name my-directive --spec directive
Changelog
1.0.0-rc.1
ngr build lib
now accepts --config
argument, can point to a JSON configuration for library packageses2015
code to be bundled with the umd
libraryes5
and umd
bundlescopy:package
field in package.json and automated this commandThis release includes a huge upgrade for library builds that allows multiple packages to be deployed from the same application. This change does not effect existing configuration and should be fully backwards compatible.
A new configuration file will be autogenerated when scaffolding a library. The JSON looks like this:
{
"src": "src/app/shared/lib",
"dist": "dist",
"filename": "default-lib",
"es2015": {
"tsConfig": "tsconfig.lib.json",
"rollupConfig": "rollup.config.lib.js",
"outFile": "dist/default-lib.js"
},
"es5": {
"tsConfig": "tsconfig.lib.es5.json",
"rollupConfig": "rollup.config.lib-es5.js",
"outFile": "dist/default-lib.es5.js"
},
"umd": {
"tsConfig": "tsconfig.lib.es5.json",
"rollupConfig": "rollup.config.lib-umd.js",
"outFile": "dist/bundles/default-lib.umd.js"
}
}
This JSON should be a sibling to the library's package.json
.
The following files can be migrated to the root folder of a library package.
tsconfig.lib.json
tsconfig.lib.es5.json
rollup.config.lib.js
rollup.config.lib-umd.js
rollup.config.lib-es5.js
The paths in tsconfig
files will have to be updated to be relative to the root directory. The library build still uses tmp
and out-tsc
folders in the root project directory during the build phase.
Here is an example:
"compilerOptions": {
"baseUrl": ".",
"rootDir": "../../../../tmp",
"outDir": "../../../../out-tsc",
...
"files": [
"../../../../tmp/index.ts"
],
You can now use the --config
argument to build a library package like so:
ngr build lib -c src/app/shared/lib/lib.config.json
This of course brings the added benefit of developing multiple library packages in the same application. Before, developers were limited to one library package per application since the build was bound to the configuration found in build.config.js
. The new format allows secondary entry points to be compiled, per the Package Format spec. This older config should still work, but it is recommended to update to this latest format to ensure future compatibility.
Changelog
1.0.0-beta.12
ngr scaffold
now defaults to a single bundle, use --lazy
to bootstrap with lazyloaded routes, --dynamicRoutes
is the samengr scaffold --electron
then build with --electron
argument. electron must be installed with npm i -g electron
.--remote
argument to production build. Allows a client to build from a host closure manifest main.prod.MF
build.config.js
must return a Promise i.e. buildHooks: {
jit: {
pre: () => {
return new Promise((res, rej) => {
// do something like copy files into /src
res();
})
}
}
}
For a client to utilize the new --remote
flag and build a lazyloaded module from a host module, the host must provide a package for the client that includes:
bundle.js
, listed in the host's main.prod.MF
bundle.js
and bundle.js.map
files to be used in the client's index.html for testing against the production bundlemain.prod.MF
The client must then copy the host's out-tsc
files into /out-tsc
during the postCompile
build step.
The client must also copy the host's main.prod.MF
into /closure
during the postCompile
build step.
The client must copy bundle.js
and bundle.js.map
into the /build
directory in the post
build step.
Here is an example of doing this with the buildHooks:
buildHooks: {
prod: {
preCompile: function (args) {
let isRemote = false;
args.forEach((arg) => {
if (arg.includes('remote')) {
isRemote = arg.split('=')[1].trim() === 'true' ? true : false;
}
});
return new Promise((res, rej) => {
if (isRemote) {
mkdir('remote');
cp(path.normalize('./path/to/host/files'), path.normalize('./remote'));
res();
} else {
res();
}
});
},
postCompile: function (args) {
let isRemote = false;
args.forEach((arg) => {
if (arg.includes('remote')) {
isRemote = arg.split('=')[1].trim() === 'true' ? true : false;
}
});
return new Promise((res, rej) => {
if (isRemote) {
cp(path.normalize('./remote/main.prod.MF'), path.normalize('./closure/main.prod.MF'));
cp('-R', path.normalize('./remote/out-tsc/*'), path.normalize('./out-tsc/'));
res();
} else {
res();
}
});
},
post: function(args) {
let isRemote = false;
args.forEach((arg) => {
if (arg.includes('remote')) {
isRemote = arg.split('=')[1].trim() === 'true' ? true : false;
}
});
if (isRemote) {
cp(path.normalize('./remote/bundle.js'), path.normalize('./build/bundle.remote.js'));
cp(path.normalize('./remote/bundle.js.map'), path.normalize('./build/bundle.remote.js.map'));
}
}
}
}
Changelog
1.0.0-beta.11
build.config.js
that allows user to do something based on process.argvChangelog
1.0.0-beta.10
This update includes the remaining major new features for 1.0.0. Leading up to 1.0.0 this project will primarily be targeting bugfixes and improvements to support @angular 5.0.0.
This update includes several improvements to scaffolding and updating apps. Both scripts now warn you that files will be overwritten. if you try to scaffold an app over an existing app or update files that already exist. The ngr update
command includes a helper argument (--cliVersion
) to track changes necessary in boilerplate files when updating. Also found in this version is a new --dynamicRoutes
option for scaffolding that allows for a dynamic route configuration on bootstrap. More concise log messages and better error reporting in the terminal are packaged with this release. The largest change to the production build is that closure Compiler is now the default bundler when running ngr build prod
.
--closure
is now the default production build, use ngr build prod --rollup
to bundle with Rollup insteadindex.html
, system.import.js
, and system.config.prod.js
to support lazyloaded bundles--dynamicRoutes
option available for scaffold and update, will scaffold app with support for configurable routes prior to bootstrap--cliVersion
will attempt to update existing boilerplate, but will not overwrite existing fileslazy.config.json
provides model for automating Closure Compiler and SystemJS polyfill for lazyloaded bundlesngr scaffold
or ngr update
system.polyfill.js
. This script requests lazy.config.json
, uses a polyfill for SystemJS to map lazyloaded bundles. This config file is only necessary for the --lazy
build.--verbose
to print more verbose messagesbundle.js
from being createdlazy.config.json
--lazy
build when two or more lazyloaded bundles shared dependencies with the main bundle--lazy
build when declaring externs in closure.externs.js
To update:
$npm install -g angular-rollup@latest
In the project directory:
$ngr update --angularVersion 4.4.4 --cliVersion 1.0.0-beta.10
$npm install
$ ngr update --cliVersion 1.0.0-beta.10
[13:17:07] LOG Review changes to angular-rollup in the CHANGELOG (https://github.com/steveblue/angular2-rollup/blob/master/CHANGELOG.md)
[13:17:07] LOG lazy.config.json copied to /Users/steveb/www/4-test/
[13:17:07] LOG system.polyfill.js copied to /Users/steveb/www/4-test/
[13:17:07] WARN src/public/system.import.js already exists
[13:17:07] WARN src/public/system.config.prod.js already exists
[13:17:07] WARN src/public/index.html already exists
[13:17:07] WARN Please move or delete existing files to prevent overwiting. Use a diff tool to track project specific changes.
The update task copies new files, warns about overwriting existing files.
If you have changed boilerplate files, you will need to diff them against the new files. Copy the files into a temporary directory and run the command again, then diff the existing files to check for project specific changes.
If you do not have changes to the boilerplate files, just remove the files and run the command again.
Changelog
1.0.0-beta.8
Changelog
1.0.0-beta.7
ngr generate wizard
g
as shorthand for generate
Example of output from the wizard:
$ ngr generate wizard
$ ngr codegen wizard
$ filename: kabab-case filename i.e. global-header
$ directory: path/to/folder i.e. src/app/shared/components/global-header
$ type: module, component, directive, enum, e2e, guard, interface, pipe, service
$ Follow the prompts after selecting a type
filename: global-header
directory: src/app/shared/components/global-header
type: module
component: y
directive: n
routes: n
unit: y
e2e: n
[15:38:18] LOG global-header.component.html copied to global-header
[15:38:18] LOG global-header.component.scss copied to global-header
[15:38:18] LOG global-header.component.ts copied to global-header
[15:38:18] LOG global-header.module.spec.ts copied to global-header
[15:38:18] LOG global-header.module.ts copied to global-header