Skip to content

Commit

Permalink
fix(polyfills): move polyfills to scripts array
Browse files Browse the repository at this point in the history
Polyfills found in polyfills.ts would not be available for scripts due to being loaded in the main bundle only.

Fix #2752
Fix #3309
  • Loading branch information
filipesilva committed Jan 3, 2017
1 parent 2a513ca commit e1506f0
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 29 deletions.
2 changes: 0 additions & 2 deletions packages/angular-cli/blueprints/ng2/files/__path__/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './polyfills.ts';

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
Expand Down
19 changes: 0 additions & 19 deletions packages/angular-cli/blueprints/ng2/files/__path__/polyfills.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/angular-cli/blueprints/ng2/files/__path__/test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './polyfills.ts';

import 'zone.js/dist/long-stack-trace-zone';
import 'zone.js/dist/proxy.js';
import 'zone.js/dist/sync-test';
Expand Down
5 changes: 4 additions & 1 deletion packages/angular-cli/blueprints/ng2/files/angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
"styles": [
"styles.<%= styleExt %>"
],
"scripts": [],
"scripts": [
"<%= relativeRootPath %>/node_modules/core-js/client/shim.min.js",
"<%= relativeRootPath %>/node_modules/zone.js/dist/zone.js"
],
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/tests/build/scripts-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ export default function () {
})
.then(() => updateJsonFile('angular-cli.json', configJson => {
const app = configJson['apps'][0];
app['scripts'] = [
app['scripts'] = app['scripts'].concat([
'string-script.js',
{ input: 'input-script.js' },
{ input: 'lazy-script.js', lazy: true },
{ input: 'pre-rename-script.js', output: 'renamed-script' },
{ input: 'pre-rename-lazy-script.js', output: 'renamed-lazy-script', lazy: true },
{ input: 'common-entry-script.js', output: 'common-entry' }
];
]);
app['styles'] = [{ input: 'common-entry-style.css', output: 'common-entry' }];
}))
.then(() => ng('build'))
Expand Down
5 changes: 4 additions & 1 deletion tests/e2e/tests/build/styles/styles-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export default function () {
{ input: 'pre-rename-lazy-style.css', output: 'renamed-lazy-style', lazy: true },
{ input: 'common-entry-style.css', output: 'common-entry' }
];
app['scripts'] = [{ input: 'common-entry-script.js', output: 'common-entry' }];
app['scripts'] = app['scripts'].concat(
[{ input: 'common-entry-script.js', output: 'common-entry' }]
);
}))
.then(() => ng('build'))
// files were created successfully
Expand All @@ -52,6 +54,7 @@ export default function () {
`))
.then(() => expectFileToMatch('dist/index.html', oneLineTrim`
<script type="text/javascript" src="inline.bundle.js"></script>
<script type="text/javascript" src="scripts.bundle.js"></script>
<script type="text/javascript" src="vendor.bundle.js"></script>
<script type="text/javascript" src="common-entry.bundle.js"></script>
<script type="text/javascript" src="main.bundle.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/tests/test/test-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ export default function () {
.then(() => expectToFail(() => ng('test', '--single-run')))
.then(() => updateJsonFile('angular-cli.json', configJson => {
const app = configJson['apps'][0];
app['scripts'] = [
app['scripts'] = app['scripts'].concat([
'string-script.js',
{ input: 'input-script.js' }
];
]);
}))
// should pass now
.then(() => ng('test', '--single-run'));
Expand Down

0 comments on commit e1506f0

Please sign in to comment.