Skip to content

Commit

Permalink
fix: don't generate minified UMD bundles.
Browse files Browse the repository at this point in the history
In version 12, applications will only be allowed to be built in Ivy, this makes the minified UMDs redundant since they cannot be processed by NGCC.

With this change, we remove the minified UMDs from the generated APF package.

BREAKING CHANGE:

Minified UMD bundles are no longer generated.
  • Loading branch information
alan-agius4 committed Apr 15, 2021
1 parent f4679f5 commit cf56f3b
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 203 deletions.
12 changes: 6 additions & 6 deletions integration/samples/apf/specs/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ describe('@sample/apf', () => {
});

describe('dist', () => {
it('should contain a total of 82 files', () => {
it('should contain a total of 75 files', () => {
// this is a safe guard / alternative to snapshots in order to
// protect ourselves from doing a change that will emit unexpected files.
const files = glob.sync(path.join(DIST, '**/*'));
expect(files.length).to.equals(83);
expect(files.length).to.equals(75);
});

it(`should contain a README.md file`, () => {
Expand Down Expand Up @@ -44,12 +44,12 @@ describe('@sample/apf', () => {
});

describe('UMD', () => {
it(`should contain 8 '.js.map' files`, () => {
expect(glob.sync(`${DIST}/bundles/**/*.js.map`).length).equal(8);
it(`should contain 4 '.js.map' files`, () => {
expect(glob.sync(`${DIST}/bundles/**/*.js.map`).length).equal(4);
});

it(`should contain 8 '.js' files`, () => {
expect(glob.sync(`${DIST}/bundles/**/*.js`).length).equal(8);
it(`should contain 4 '.js' files`, () => {
expect(glob.sync(`${DIST}/bundles/**/*.js`).length).equal(4);
});
});

Expand Down
21 changes: 0 additions & 21 deletions integration/samples/core/specs/sourcemaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,4 @@ describe(`@sample/core`, () => {
expect(sourceMap.sources[0]).to.equal('../../src/angular.component.ts');
});
});

describe(`bundles/sample-core.umd.min.js.map`, () => {
let sourceMap;
before(() => {
sourceMap = fs.readJsonSync(path.resolve(__dirname, '../dist/bundles/sample-core.umd.min.js.map'));
});

it(`should exist`, () => {
expect(sourceMap).to.be.ok;
});

it(`should not have any 'null' in sources`, () => {
expect(sourceMap.sources.includes(null)).to.be.false;
});

it(`should have 'sources' and 'sourcesContent' property`, () => {
expect(sourceMap.sources).to.be.an('array').that.is.not.empty;
expect(sourceMap.sourcesContent).to.be.an('array').that.is.not.empty;
expect(sourceMap.sources).to.have.lengthOf(sourceMap.sourcesContent.length);
});
});
});
40 changes: 0 additions & 40 deletions integration/samples/core/specs/umd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,44 +25,4 @@ describe(`@sample/core`, () => {
expect(BUNDLE).not.to.contain('tslib');
});
});

describe(`sample-core.umd.min.js`, () => {
let API;
before(() => {
API = require('../dist/bundles/sample-core.umd.min.js');
});

it(`should exist`, () => {
expect(API).to.be.ok;
});

it(`should export AngularComponent`, () => {
expect(API.AngularComponent).to.be.ok;
});

it(`should export AngularDirective`, () => {
expect(API.AngularDirective).to.be.ok;
});

it(`should export AngularModule`, () => {
expect(API.AngularModule).to.be.ok;
});

it(`should export AngularPipe`, () => {
expect(API.AngularPipe).to.be.ok;
});

it(`should export AngularService`, () => {
expect(API.AngularService).to.be.ok;
});

it(`should downlevel iteration`, () => {
const iterable = function*() {
yield* [1, 2, 3];
};
const values = API.AngularService.iterableToArray(iterable());

expect(values).to.deep.equal([1, 2, 3]);
});
});
});
2 changes: 1 addition & 1 deletion integration/samples/externals/specs/umd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe(`@sample/externals`, () => {
BUNDLE = fs.readFileSync(path.resolve(__dirname, '../dist/bundles/sample-externals.umd.js'), {
encoding: 'utf-8',
});
API = require('../dist/bundles/sample-externals.umd.min.js');
API = require('../dist/bundles/sample-externals.umd.js');
});

it(`should export 'target$'`, () => {
Expand Down
41 changes: 0 additions & 41 deletions integration/samples/same-name/specs/umd.ts

This file was deleted.

32 changes: 0 additions & 32 deletions integration/samples/secondary/specs/umd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,6 @@ describe(`@sample/secondary`, () => {
});
});

describe(`sample-secondary.umd.min.js`, () => {
let GENERATED;
before(done => {
GENERATED = require('../dist/bundles/sample-secondary.umd.min.js');
done();
});

it(`should exist`, () => {
expect(GENERATED).to.be.ok;
});

it(`should have "BazComponent"`, () => {
expect(GENERATED.BazComponent).to.be.ok;
});
});

describe(`sample-secondary-sub-module.umd.js`, () => {
let GENERATED;
before(done => {
Expand All @@ -48,20 +32,4 @@ describe(`@sample/secondary`, () => {
expect(GENERATED.BarComponent).to.be.ok;
});
});

describe(`sample-secondary-sub-module.umd.min.js`, () => {
let GENERATED;
before(done => {
GENERATED = require('../dist/bundles/sample-secondary-sub-module.umd.min.js');
done();
});

it(`should exist`, () => {
expect(GENERATED).to.be.ok;
});

it(`should have "BarComponent"`, () => {
expect(GENERATED.BarComponent).to.be.ok;
});
});
});
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
"rollup-plugin-sourcemaps": "^0.6.3",
"rxjs": "^6.5.0",
"sass": "^1.32.5",
"stylus": "^0.54.8",
"terser": "^5.5.1"
"stylus": "^0.54.8"
},
"peerDependencies": {
"@angular/compiler": "^12.0.0-next.0",
Expand Down
33 changes: 0 additions & 33 deletions src/lib/flatten/uglify.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/lib/ng-package/entry-point/entry-point.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe(`NgEntryPoint`, () => {
expect(primaryEntryPoint.entryFilePath).to.equal(resolve(testSourcePath, 'public-api.ts'));
expect(primaryEntryPoint.isSecondaryEntryPoint).to.be.false;
expect(primaryEntryPoint.destinationPath).to.equal(resolve(testDestinationPath));
expect(Object.keys(primaryEntryPoint.destinationFiles).length).to.equal(6);
expect(Object.keys(primaryEntryPoint.destinationFiles).length).to.equal(5);
expect(primaryEntryPoint.entryFile).to.equal('public-api.ts');
expect(primaryEntryPoint.cssUrl).to.be.undefined; // TODO: should default to 'inline'.
expect(primaryEntryPoint.umdModuleIds).to.be.undefined;
Expand Down Expand Up @@ -112,7 +112,7 @@ describe(`NgEntryPoint`, () => {
expect(secondaryEntryPoint.entryFilePath).to.equal(resolve(secondaryEntryPointBasePath, 'public-api.ts'));
expect(secondaryEntryPoint.isSecondaryEntryPoint).to.be.true;
expect(secondaryEntryPoint.destinationPath).to.equal(resolve(secondaryData.destinationPath));
expect(Object.keys(secondaryEntryPoint.destinationFiles).length).to.equal(6);
expect(Object.keys(secondaryEntryPoint.destinationFiles).length).to.equal(5);
expect(secondaryEntryPoint.entryFile).to.equal('public-api.ts');
expect(secondaryEntryPoint.cssUrl).to.be.undefined; // TODO: should default to 'inline'.
expect(secondaryEntryPoint.umdModuleIds).to.be.undefined;
Expand Down
3 changes: 0 additions & 3 deletions src/lib/ng-package/entry-point/entry-point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ export interface DestinationFiles {
esm2015: string;
/** Absolute path of this entry point `UMD` bundle */
umd: string;
/** Absolute path of this entry point `UMD` minified bundle */
umdMinified: string;
}

/**
Expand Down Expand Up @@ -96,7 +94,6 @@ export class NgEntryPoint {
esm2015: pathJoinWithDest('esm2015', secondaryDir, `${flatModuleFile}.js`),
fesm2015: pathJoinWithDest('fesm2015', `${flatModuleFile}.js`),
umd: pathJoinWithDest('bundles', `${flatModuleFile}.umd.js`),
umdMinified: pathJoinWithDest('bundles', `${flatModuleFile}.umd.min.js`),
};
}

Expand Down
7 changes: 1 addition & 6 deletions src/lib/ng-package/entry-point/write-bundles.transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { DependencyList } from '../../flatten/external-module-id-strategy';
import { unique } from '../../utils/array';
import { downlevelCodeWithTsc } from '../../flatten/downlevel-plugin';
import { rollupBundleFile } from '../../flatten/rollup';
import { minifyJsFile } from '../../flatten/uglify';
import { NgPackagrOptions } from '../options.di';

export const writeBundlesTransform = (options: NgPackagrOptions) => transformFromPromise(async graph => {
Expand All @@ -26,7 +25,7 @@ export const writeBundlesTransform = (options: NgPackagrOptions) => transformFro
return prev;
}, {});

const { fesm2015, esm2015, umd, umdMinified } = destinationFiles;
const { fesm2015, esm2015, umd } = destinationFiles;

const opts = {
sourceRoot: tsConfig.options.sourceRoot,
Expand Down Expand Up @@ -71,10 +70,6 @@ export const writeBundlesTransform = (options: NgPackagrOptions) => transformFro
transform: downlevelCodeWithTsc,
});
spinner.succeed();

spinner.start('Minifying UMD bundle');
await minifyJsFile(umd, umdMinified);
spinner.succeed();
} catch (error) {
spinner.fail();
throw error;
Expand Down
18 changes: 2 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1114,11 +1114,6 @@ colorette@^1.2.1, colorette@^1.2.2:
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94"
integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==

commander@^2.20.0:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==

commander@^7.0.0, commander@^7.1.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7"
Expand Down Expand Up @@ -4131,7 +4126,7 @@ source-map-resolve@^0.6.0:
atob "^2.1.2"
decode-uri-component "^0.2.0"

source-map-support@^0.5.17, source-map-support@~0.5.19:
source-map-support@^0.5.17:
version "0.5.19"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"
integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==
Expand All @@ -4154,7 +4149,7 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0:
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==

source-map@^0.7.0, source-map@^0.7.3, source-map@~0.7.2:
source-map@^0.7.0, source-map@^0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==
Expand Down Expand Up @@ -4384,15 +4379,6 @@ svgo@^2.3.0:
csso "^4.2.0"
stable "^0.1.8"

terser@^5.5.1:
version "5.6.1"
resolved "https://registry.yarnpkg.com/terser/-/terser-5.6.1.tgz#a48eeac5300c0a09b36854bf90d9c26fb201973c"
integrity sha512-yv9YLFQQ+3ZqgWCUk+pvNJwgUTdlIxUk1WTN+RnaFJe2L7ipG2csPT0ra2XRm7Cs8cxN7QXmK1rFzEwYEQkzXw==
dependencies:
commander "^2.20.0"
source-map "~0.7.2"
source-map-support "~0.5.19"

text-extensions@^1.0.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.9.0.tgz#1853e45fee39c945ce6f6c36b2d659b5aabc2a26"
Expand Down

0 comments on commit cf56f3b

Please sign in to comment.