Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(@angular/cli): support sourcemaps and minification in scripts #7279

Merged
merged 1 commit into from
Aug 17, 2017

Conversation

filipesilva
Copy link
Contributor

@filipesilva filipesilva commented Aug 4, 2017

Adds sourcemap and minification to javascript added via the scripts array in .angular-cli.json.

script-loader is no longer used, which should help with CSP since it used eval.

Scripts will no longer appear in the console output for ng build, as they are now assets instead of webpack entry points.

It's no longer possible to have the output property of both a scripts and a styles entry pointing to the same file. This wasn't officially supported or listed in the docs, but used to be possible.

Fix #2796
Fix #7226
Fix #7290

Related to #6872

@filipesilva filipesilva force-pushed the scripts-uglify-sourcemaps branch 4 times, most recently from 94e9bdc to 27332f0 Compare August 9, 2017 12:37
@filipesilva filipesilva force-pushed the scripts-uglify-sourcemaps branch 6 times, most recently from 6518767 to 3ab491b Compare August 15, 2017 16:02
@filipesilva filipesilva requested review from hansl and Brocco August 15, 2017 16:07
@filipesilva filipesilva self-assigned this Aug 15, 2017
@filipesilva
Copy link
Contributor Author

This PR also ensures lazy loaded scripts do not have a hash. There wasn't an issue opened for that but it was a bug.

@filipesilva filipesilva force-pushed the scripts-uglify-sourcemaps branch from 3ab491b to 02c28b3 Compare August 16, 2017 13:37
Adds sourcemap and minification to javascript added via the `scripts` array in `.angular-cli.json`.

`script-loader` is no longer used, which should help with CSP since it used `eval`.

Scripts will no longer appear in the console output for `ng build`, as they are now assets instead of webpack entry points.

It's no longer possible to have the `output` property of both a `scripts` and a `styles` entry pointing to the same file. This wasn't officially supported or listed in the docs, but used to be possible.

Fix angular#2796
Fix angular#7226
Fix angular#7290

Related to angular#6872
@filipesilva filipesilva force-pushed the scripts-uglify-sourcemaps branch from 02c28b3 to 08b514a Compare August 17, 2017 19:16
@Brocco Brocco merged commit e8f27f0 into angular:master Aug 17, 2017
@filipesilva filipesilva deleted the scripts-uglify-sourcemaps branch August 21, 2017 12:09
@franktroia
Copy link

Does this also resolve #6166?

@franktroia
Copy link

franktroia commented Aug 30, 2017

I tried a quick update to cli 1.4.0.rc2 to test this out but quickly ran into issues.

We're loading our legacy scripts and vendor files using global scripts. I'm a little bit out of my wheel house here, but it seems that with the new loader, "this" is not automatically bound to Window. Instead "this" is undefined.

For instance, the sample script below will no longer work, as "this" is undefined.

(function() {
  var body = this.jQuery('body');
})();

Downgrading to cli 1.3.2 will allow the script above to work.

Needless to say, this cause complete havoc on our legacy scripts and vendor scripts.

@filipesilva
Copy link
Contributor Author

Heya @franktroia, thanks for testing this feature. I'm very interested in the problem you're having, but couldn't reproduce it.

On a new project I added src/script.js to the .angular-cli.json, with the following content:

(function () {
  console.log(this)
})();

Then ran ng serve, opened a browser window, and saw Window being printed by the console.log:

image

Can you open a new issue with a repro and ping me on it so I can investigate?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants