Angular-cli: `scripts.bundle.js` not rebuilding when file included in `scripts` changes

Created on 25 Sep 2017  路  12Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

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

Versions.

@angular/cli: 1.4.3
node: 6.7.0
os: darwin x64
@angular/animations: 4.4.3
@angular/common: 4.4.3
@angular/compiler: 4.4.3
@angular/core: 4.4.3
@angular/forms: 4.4.3
@angular/http: 4.4.3
@angular/platform-browser: 4.4.3
@angular/platform-browser-dynamic: 4.4.3
@angular/router: 4.4.3
@angular/cli: 1.4.3
@angular/compiler-cli: 4.4.3
@angular/language-service: 4.4.3
typescript: 2.3.4

Repro steps.

ng new scriptsTest
cd scriptsTest
echo "console.log('hello')" > ./src/update.js

Update .angular-cli.json to include update.js in scripts, e.g.

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "scripts-test"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "styles.css"
      ],
      "scripts": ["update.js"],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "src/tsconfig.spec.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "e2e/tsconfig.e2e.json",
      "exclude": "**/node_modules/**"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}

Run ng serve and open the webpage.

You will see hello logged to the console.

Now edit the src/update.js file, change it to console.log('hello world');

Webpack will trigger a rebuild of all the other bundles, but scripts bundle will stay the same. The page will reload, and the console will log hello again, instead of hello world.

Restarting the build completely is the only way to get the change.

Desired functionality.

We'd like to see the external script changes trigger an update to the scripts.bundle.js. We're using scripts to include our ng1 bundle, and our changes to that bundle are not getting built.

Mention any other details that might be useful.

This might be related to this commit: https://github.com/angular/angular-cli/commit/e8f27f0

1 (urgent) regression bufix

Most helpful comment

Setting cli to 1.4.2 doesn't seem to help.

Example project which demonstrates the issue can be found there.

All 12 comments

Just as note for anyone effected by this, pin your cli version to "@angular/cli": "1.4.2" (without the ^), and scripts will work as intended.

Setting cli to 1.4.2 doesn't seem to help.

Example project which demonstrates the issue can be found there.

same issue using latest ng 1.5.3
scripts files not being included :(

I'm having the same issue. using "@angular/cli": "1.5.0"

Same issue here

I am facing the same problem,
With both

"devDependencies": { "@angular/cli": "1.1.3", "@angular/compiler-cli": "^4.0.0", "@angular/language-service": "^4.0.0", "@types/jasmine": "2.5.45", "@types/node": "~6.0.60", "codelyzer": "~3.0.1", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.1.2", "ts-node": "~3.0.4", "tslint": "~5.3.2", "typescript": "~2.3.3" }

AND

"devDependencies": { "@angular/cli": "1.5.5", "@angular/compiler-cli": "^5.0.0", "@angular/language-service": "^5.0.0", "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", "codelyzer": "^4.0.1", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.1.2", "ts-node": "~3.2.0", "tslint": "~5.7.0", "typescript": "~2.4.2" }

@filipesilva can you please help resolving this issue?

This should be corrected in 1.6.3. If the problem still occurs, please re-open the issue.

I am getting "Uncaught ReferenceError: ng is not defined
at scripts.bundle.js:1644" on console

plz help

Not working. Im using the CLI 1.7.4 and still not including the JS files.
what is going on?? please help

I was facing the same issue. Apparently, I had added the scripts under test in json file.

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._

Was this page helpful?
0 / 5 - 0 ratings