3

In an angular 5 project created by the help of the Angular CLI 1.5.0, when I run the following command

ng serve

I can see that web pack starts its bundling and projects starts serving. Where does the generated transpiled js file go to? Initially I thought this location should be the one mentioned in

tsconfig.json , OutDir

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2017",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

but funnily enough I can't seem to find that outdir folder inside the project folder. I've also checked the angular-cli.json file

  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      ......
      ......   

but I still can't find the transpiled js files. What am I missing or doing wrong? Where are the java-script files for my .ts files?

4
  • 2
    When using ng serve, the transpiled files are held in memory, not on disk. To generate the transpiled files for deployment etc, use ng build. Commented Nov 8, 2017 at 13:42
  • That definitely explains why those js files are not there. Thanks. Commented Nov 8, 2017 at 13:48
  • How does the browser locate these in-memory files? Commented Nov 9, 2017 at 9:37
  • 1
    The browser doesnt do that. It sends (http get) requests to the embedded webserver (ng serve) which then serves those requests (replies with the in-memory files). Commented Nov 9, 2017 at 9:44

1 Answer 1

2

ng serve keeps transpiled files in memory and does not write to disk. You need to do ng build --watch to get it to write to disk and also update with changes.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.