angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng build --aot --prod generates ESC character in vendor

Open robindijkhof opened this issue 9 years ago • 15 comments

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.0.0 node: 6.10.2 os: win32 x64 @angular/common: 4.1.0 @angular/compiler: 4.1.0 @angular/core: 4.1.0 @angular/forms: 4.1.0 @angular/http: 4.1.0 @angular/platform-browser: 4.1.0 @angular/platform-browser-dynamic: 4.1.0 @angular/router: 4.1.0 @angular/cli: 1.0.0 @angular/compiler-cli: 4.1.0

Repro steps.

Create a new project with the cli run ng build --aot --prod check the vendor file. Easiest way is to open the file in notepad++. Press ALT + 027 to insert the ESC char. Ctrl + C to copy and Ctrl + F to find it.

The log given by the failure.

No angular crashlog. Crashlog from IBM WebSphere. Illegal character [0x001b] found at offset [some hex value] in file [vendor.**.bundle.js]

Desired functionality.

Don't generate the ESC char but ESC as string.

Mention any other details that might be useful.

Also happend with cli 1.0.1 I added my generated vendor. Check line 529 col 10548. https://www.dropbox.com/s/d80zz1fpxy8xho4/vendor.8b1206c372ceef779894.bundle.js?dl=0

robindijkhof avatar May 02 '17 15:05 robindijkhof

Can you provide a repro where this happens? One of your vendors seems to be doing it but I can't figure it out from just the bundle.

filipesilva avatar May 05 '17 21:05 filipesilva

Hero you go

robindijkhof avatar May 08 '17 07:05 robindijkhof

@filipesilva Any update on this one?

robindijkhof avatar May 31 '17 13:05 robindijkhof

@filipesilva I can reproduce this by making a new skeleton with ng new projectname and ng build --prod and it throws errors when we push it up to our server every time. Any updates on this or a version of the CLI we can revert to in the meantime that doesn't cause this behavior?

Fayde avatar Jun 08 '17 19:06 Fayde

@Fayde

As far as I know there is no version you can revert to. I wrote this simple gulp script for the meantime.

(gulpfile.js)

var gulp = require('gulp');
var replace = require('gulp-replace');


gulp.task('build', function () {
  console.log('replacing characters we can\'t handle');
  gulp.src(['dist/vendor.*.bundle.js'])
    .pipe(replace(/\u001b/g, '\\u001b'))
    .pipe(gulp.dest('dist'))
});`

Script: "build": "ng build --aot --prod && gulp build"

robindijkhof avatar Jun 09 '17 08:06 robindijkhof

@robindijkhof thanks I will add it into my build chain for now

Fayde avatar Jun 13 '17 15:06 Fayde

@filipesilva can we get an update on if this is being looked at or not. It's not ideal to have this step in the build chain for an enterprise-wide application and justifying to leadership that this is a necessary step but also that this is a stable application

Fayde avatar Jul 07 '17 16:07 Fayde

https://github.com/angular/angular-cli/issues/3544 <-- I think this is same issue.

chunghha avatar Jul 12 '17 16:07 chunghha

@chunghha it's not the same issue

@filipesilva any update please

Fayde avatar Jul 18 '17 20:07 Fayde

I checked out @robindijkhof's fix in https://github.com/angular/angular-cli/pull/6951 but am sorry to say this is not something we're going to merge.

As per Uglify's documentation, turning ascii_only on can break directive names. Indeed <app-root-☺></app-root-☺> is a valid directive.

Since browsers in general support unicode, I don't think the CLI prod build pipeline should drop it.

At the moment I think the problem here is that your server does not support certain unicode characters, and I think it's reasonable for users to have an extra step (such as the gulp script) to work around limitations of that server.

filipesilva avatar Jul 19 '17 09:07 filipesilva

Eyeroll

Fayde avatar Jul 19 '17 16:07 Fayde

Hello,

Are you sure it is working? Here I have created a component with a selector using unicode character, it doesn't work.

https://plnkr.co/edit/RQ6FrdVIBJD42XqDUx9t?p=preview

pierre-hilt avatar Aug 02 '17 14:08 pierre-hilt

@pierre-hilt it seems to be supported in the root component (the ones that goes in index.html) but not in the others. I'll double check unicode support with the team.

filipesilva avatar Aug 04 '17 08:08 filipesilva

I was wrong - <app-root-☺> is not a valid directive name per WC3 spec and is not meant to be supported by Angular itself.

I ran a few tests to see if it was safe to turn on ascii_only and it seemed to be fine overall. Reopening #6951 for merging.

filipesilva avatar Aug 04 '17 16:08 filipesilva

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.