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

Making changes to template breaks app #1457

Closed
enorfelt opened this issue Oct 11, 2016 · 6 comments
Closed

Making changes to template breaks app #1457

enorfelt opened this issue Oct 11, 2016 · 6 comments
Assignees
Labels

Comments

@enorfelt
Copy link

@enorfelt enorfelt commented Oct 11, 2016

I'm running the latest version (hopfully after upgrade) of seed. When I do a change in eg. home.component.html and after the live reload the app is broken with this error message:

localhost/:58 Error: (SystemJS) Unexpected token < in JSON at position 0(…) "Report this er

Steps to reproduce:

  1. npm start
  2. Make a change in home.component.html
  3. Save
  4. Wait for live reload

Current behaviour

localhost/:58 Error: (SystemJS) Unexpected token < in JSON at position 0(…) "Report this er

If I look into the file "dist/dev/app/shared/config/env.config.js" this is what is displayed:
"use strict"; exports.Config = JSON.parse('<%= ENV_CONFIG %>'); //# sourceMappingURL=env.config.js.map

Expected:
Expected content in env.config.js:
"use strict"; exports.Config = JSON.parse('{"API":"https://demo.com","APP_BASE":"/web/","ENV":"DEV"}');

Other info:
If I trigger a typescript file change then the json is evaluated and the problem is fixed.

UPDATE
I just tried this on a new clone and I can reproduce this issue. Just run the app and change something in home.component.html

@mgechev
Copy link
Owner

@mgechev mgechev commented Oct 11, 2016

Thanks, I will work on this issue today.

@mgechev mgechev self-assigned this Oct 11, 2016
@mgechev mgechev added bug P1 labels Oct 11, 2016
@mgechev
Copy link
Owner

@mgechev mgechev commented Oct 11, 2016

I cannot reproduce your issue. Would you take a look at your tools directory and verify if you haven't compiled the typescript files?

@mgechev mgechev added discuss and removed bug P1 labels Oct 11, 2016
@enorfelt
Copy link
Author

@enorfelt enorfelt commented Oct 11, 2016

Thats strange! Just tried on another computer right now with the same result.
Steps:

  1. git clone --depth 1 https://github.com/mgechev/angular-seed.git
  2. cd angular-seed
  3. npm install
  4. tsc --project tsconfig.json (All ts files are compiled in tools folder)
  5. npm start (App runs without a problem)
  6. Change/Saved home.component.html
  7. App breaks with the same error. dist/dev/app/shared/config/env.config.js contains:
    "use strict"; exports.Config = JSON.parse('<%= ENV_CONFIG %>'); //# sourceMappingURL=env.config.js.map
  8. Changed/saved home.component.ts
  9. App compiles and reloads and the app works again. dist/dev/app/shared/config/env.config.js contains:
    `"use strict";
    exports.Config = JSON.parse('{"API":"https://demo.com","ENV":"DEV"}');

//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC9zaGFyZWQvY29uZmlnL2Vudi5jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQU9hLGNBQU0sR0FBYyxJQUFJLENBQUMsS0FBSyxDQUFDLG1CQUFtQixDQUFDLENBQUMiLCJmaWxlIjoiYXBwL3NoYXJlZC9jb25maWcvZW52LmNvbmZpZy5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vIEZlZWwgZnJlZSB0byBleHRlbmQgdGhpcyBpbnRlcmZhY2VcclxuLy8gZGVwZW5kaW5nIG9uIHlvdXIgYXBwIHNwZWNpZmljIGNvbmZpZy5cclxuZXhwb3J0IGludGVyZmFjZSBFbnZDb25maWcge1xyXG4gIEFQST86IHN0cmluZztcclxuICBFTlY/OiBzdHJpbmc7XHJcbn1cclxuXHJcbmV4cG9ydCBjb25zdCBDb25maWc6IEVudkNvbmZpZyA9IEpTT04ucGFyc2UoJzwlPSBFTlZfQ09ORklHICU+Jyk7XHJcblxyXG4iXX0=`

I have a feeling that the env.config.js is copied to output directory even though it has not changed.
If I look at the last modified date of dist/dev/app/shared/config/env.config.js it's the same time stamp as I saved the home.component.html file. So indeed it gets copied over.

Using:
Windows 10
Visual Studio Code 1.6.0
Powershell (For compiling and running build/run tasks)
Node version 5.7.0
npm version 3.6.0

Help or input is much appreciated :) Can I debug it some how?

@enorfelt
Copy link
Author

@enorfelt enorfelt commented Oct 12, 2016

I think I figured it out! It's the "extra" tsc --project tsconfig.json command that messes things up.
Event though the "src" directory is excluded in the tsconfig.json the "src/.../config/env.config.ts" is referenced under the tools directory and gets complied anyhow. I think this is how it must work?
As it is complied the complied "js" file ends up in the same directory under src.
srcenvconfig

When I save the "home.component.html" and the task "build.assets.dev" is ran, any *.js file under the "src" folder is copied to the "dest" folder.
buildassetsdev

Maby we need to exclude more files/fodlers in the above list? Can you reproduce if you run "tsc --project tsconfig.json"?

@jimmybillings
Copy link

@jimmybillings jimmybillings commented Oct 12, 2016

I'm seeing the same issue. Running npm start works fine, however after a rebuild because of a change all of the HTML files are blown away in the dist/dev folder. I can't figure out what is causing it because it looks like it goes through the exact same process as when you first run npm start.

FYI - everything seems to work fine when running in start.deving mode except my laptop sounds like a Harley Davidson.

@Bigous
Copy link
Contributor

@Bigous Bigous commented Oct 14, 2016

Ok, first of all, you don't run tsc directly... There is a gulp script to do lots of things when building the seed.
One could work like this:

$ git clone --depth 1 https://githib.com/mgechev/angular-seed
$ cd angular-seed
$ npm install
$ npm start

The npm start will handle the build and everything else you need to run the seed.

Then you can edit the components, etc...

Mine worked

Using:
Windows 10
node 6.7.0
npm 3.10.3
bash 4.3.42 (from git)
VSCode 1.6.1

@mgechev mgechev closed this Oct 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.