From 0cb0cce2c241e38b4228bfeb6c700dd0ec3ebd72 Mon Sep 17 00:00:00 2001 From: David Herges Date: Sat, 3 Feb 2018 09:22:22 +0100 Subject: [PATCH] fix: update rollup to version `^0.55.0` (#534) Closes #488, #523 --- package.json | 8 ++--- src/lib/flatten/flatten.ts | 6 ++-- src/lib/flatten/rollup.ts | 32 ++++++++++++------- .../ts/analyse-sources.transform.ts | 2 +- yarn.lock | 19 +++-------- 5 files changed, 32 insertions(+), 35 deletions(-) diff --git a/package.json b/package.json index 2d2981224..a3a4b285f 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "postcss-discard-comments": "^2.0.4", "postcss-url": "^7.3.0", "rimraf": "^2.6.1", - "rollup": "0.53.0", + "rollup": "^0.55.0", "rollup-plugin-commonjs": "^8.2.1", "rollup-plugin-node-resolve": "^3.0.0", "rxjs": "^5.5.0", @@ -54,8 +54,8 @@ "peerDependencies": { "@angular/compiler": "^5.0.0", "@angular/compiler-cli": "^5.0.0", - "tslib": "^1.7.1", "tsickle": ">=0.25.5", + "tslib": "^1.7.1", "typescript": ">=2.4.2" }, "devDependencies": { @@ -70,6 +70,7 @@ "@angular/platform-browser": "~5.2.0", "@commitlint/cli": "^6.0.0", "@commitlint/config-angular": "^6.0.2", + "@types/acorn": "^4.0.3", "@types/chai": "^4.0.0", "@types/cpx": "^1.5.0", "@types/fs-extra": "^5.0.0", @@ -80,7 +81,6 @@ "@types/node": "^9.3.0", "@types/react": "^16.0.19", "@types/react-dom": "^16.0.2", - "@types/rollup": "^0.51.2", "@types/sinon": "^4.0.0", "@types/strip-bom": "^3.0.0", "chai": "^4.0.1", @@ -98,8 +98,8 @@ "sinon": "^4.0.0", "standard-version": "^4.0.0", "ts-node": "^4.0.0", - "tslib": "^1.7.1", "tsickle": "^0.26.0", + "tslib": "^1.7.1", "typescript": "~2.6.1", "zone.js": "^0.8.10" }, diff --git a/src/lib/flatten/flatten.ts b/src/lib/flatten/flatten.ts index 7ba912677..a05b81404 100644 --- a/src/lib/flatten/flatten.ts +++ b/src/lib/flatten/flatten.ts @@ -1,7 +1,7 @@ import * as path from 'path'; import { remapSourceMap } from '../sourcemaps/remap'; import * as log from '../util/log'; -import { rollup } from './rollup'; +import { rollupBundleFile } from './rollup'; import { downlevelWithTsc } from './tsc'; import { minifyJsFile } from './uglify'; @@ -40,7 +40,7 @@ export async function writeFlatBundleFiles(opts: FlattenOpts) { export async function flattenToFesm15(opts: FlattenOpts): Promise { const destFile = path.resolve(opts.outDir, 'esm2015', opts.flatModuleFile + '.js'); - await rollup({ + await rollupBundleFile({ moduleName: opts.esmModuleId, entry: opts.entryFile, format: 'es', @@ -63,7 +63,7 @@ export async function flattenToUmd(opts: FlattenOpts): Promise { const destFile = path.resolve(opts.outDir, 'bundles', opts.flatModuleFile + '.umd.js'); const { embedded = [] } = opts; - await rollup({ + await rollupBundleFile({ moduleName: opts.umdModuleId, entry: opts.entryFile, format: 'umd', diff --git a/src/lib/flatten/rollup.ts b/src/lib/flatten/rollup.ts index 60ff21410..12a6e3af6 100644 --- a/src/lib/flatten/rollup.ts +++ b/src/lib/flatten/rollup.ts @@ -1,4 +1,4 @@ -import * as __rollup from 'rollup'; +import * as rollup from 'rollup'; import * as nodeResolve from 'rollup-plugin-node-resolve'; import * as commonJs from 'rollup-plugin-commonjs'; import * as path from 'path'; @@ -6,34 +6,42 @@ import * as log from '../util/log'; import { externalModuleIdStrategy } from './external-module-id-strategy'; import { umdModuleIdStrategy } from './umd-module-id-strategy'; -export type BundleFormat = __rollup.Format; - +/** + * Options used in `ng-packagr` for writing flat bundle files. + * + * These options are passed through to rollup. + */ export interface RollupOptions { moduleName: string; entry: string; - format: BundleFormat; + format: rollup.ModuleFormat; dest: string; umdModuleIds?: { [key: string]: string }; embedded?: string[]; } /** Runs rollup over the given entry file, writes a bundle file. */ -export async function rollup(opts: RollupOptions): Promise { - log.debug(`rollup (v${__rollup.VERSION}) ${opts.entry} to ${opts.dest} (${opts.format})`); +export async function rollupBundleFile(opts: RollupOptions): Promise { + log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dest} (${opts.format})`); // Create the bundle - const bundle: __rollup.Bundle = await __rollup.rollup({ + const bundle: rollup.OutputChunk = await rollup.rollup({ context: 'this', external: moduleId => externalModuleIdStrategy(moduleId, opts.embedded || []), input: opts.entry, plugins: [nodeResolve({ jsnext: true, module: true }), commonJs()], onwarn: warning => { - if (warning.code === 'THIS_IS_UNDEFINED') { - return; - } + if (typeof warning === 'string') { + log.warn(warning); + } else { + if (warning.code === 'THIS_IS_UNDEFINED') { + return; + } - log.warn(warning.message); - } + log.warn(warning.message); + } + }, + preserveSymlinks: true }); // Output the bundle to disk diff --git a/src/lib/ng-v5/entry-point/ts/analyse-sources.transform.ts b/src/lib/ng-v5/entry-point/ts/analyse-sources.transform.ts index 23f162ff5..05400f39a 100644 --- a/src/lib/ng-v5/entry-point/ts/analyse-sources.transform.ts +++ b/src/lib/ng-v5/entry-point/ts/analyse-sources.transform.ts @@ -13,7 +13,7 @@ import { byEntryPoint, isInProgress } from '../../entry-point.node'; export const analyseSourcesTransform: Transform = pipe( map(graph => { const entryPoint = graph.find(byEntryPoint().and(isInProgress)); - log.debug(`Analyzing sources for ${entryPoint.data.entryPoint.moduleId}`); + log.debug(`Analysing sources for ${entryPoint.data.entryPoint.moduleId}`); const tsConfig = entryPoint.data.tsConfig; diff --git a/yarn.lock b/yarn.lock index ac0161385..0c065e3b9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -178,7 +178,7 @@ version "1.1.0" resolved "https://registry.yarnpkg.com/@ngtools/json-schema/-/json-schema-1.1.0.tgz#c3a0c544d62392acc2813a42c8a0dc6f58f86922" -"@types/acorn@*": +"@types/acorn@^4.0.3": version "4.0.3" resolved "https://registry.yarnpkg.com/@types/acorn/-/acorn-4.0.3.tgz#d1f3e738dde52536f9aad3d3380d14e448820afd" dependencies: @@ -264,13 +264,6 @@ version "16.0.28" resolved "https://registry.yarnpkg.com/@types/react/-/react-16.0.28.tgz#eb0b31272528da8f20477ec27569c4f767315b33" -"@types/rollup@^0.51.2": - version "0.51.2" - resolved "https://registry.yarnpkg.com/@types/rollup/-/rollup-0.51.2.tgz#1b1b868e6f79be444916a7611914c0049914d547" - dependencies: - "@types/acorn" "*" - "@types/source-map" "*" - "@types/sinon@^4.0.0": version "4.1.0" resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-4.1.0.tgz#cdfb934d656b2c888e51f53e95900c7bbca11c08" @@ -281,10 +274,6 @@ dependencies: "@types/node" "*" -"@types/source-map@*": - version "0.5.2" - resolved "https://registry.yarnpkg.com/@types/source-map/-/source-map-0.5.2.tgz#973459e744cc7445c85b97f770275b479b138e08" - "@types/strip-bom@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2" @@ -2969,9 +2958,9 @@ rollup-pluginutils@^2.0.1: estree-walker "^0.3.0" micromatch "^2.3.11" -rollup@0.53.0: - version "0.53.0" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.53.0.tgz#7a3d5a04ba2b0a8f2405899fa6a0ac48da480ed1" +rollup@^0.55.0: + version "0.55.3" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.55.3.tgz#0af082a766d51c3058430c8372442ff5207d8736" rxjs@^5.5.0, rxjs@^5.5.6: version "5.5.6"