angular/ngcc-validation

@ionic/angular

mhartington opened this issue · 7 comments

$ npx ivy-ngcc -p tsconfig.json
Error: Failed to compile any formats for entry-point at (/Users/mhartington/GitHub/ionic/angular/node_modules/@angular/animations). Tried tsconfig.json.
    at Object.mainNgcc (/Users/mhartington/GitHub/ionic/angular/node_modules/@angular/compiler-cli/ngcc/src/main.js:111:27)
    at /Users/mhartington/GitHub/ionic/angular/node_modules/@angular/compiler-cli/ngcc/main-ngcc.js:68:20
    at /Users/mhartington/GitHub/ionic/angular/node_modules/@angular/compiler-cli/ngcc/main-ngcc.js:4:17
    at Object.<anonymous> (/Users/mhartington/GitHub/ionic/angular/node_modules/@angular/compiler-cli/ngcc/main-ngcc.js:10:3)
    at Module._compile (internal/modules/cjs/loader.js:777:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:788:10)
    at Module.load (internal/modules/cjs/loader.js:643:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:840:10)
    at /Users/mhartington/n/lib/node_modules/npm/node_modules/libnpx/index.js:268:14

Hi @mhartington, -p is short hand for --properties.

npx ivy-ngcc --help
Options:
  --version         Show version number                                [boolean]
  -s, --source      A path (relative to the working directory) of the
                    `node_modules` folder to process.[default: "./node_modules"]
  -p, --properties  An array of names of properties in package.json to compile
                    (e.g. `module` or `es2015`)
                    Each of these properties should hold the path to a
                    bundle-format.
                    If provided, only the specified properties are considered
                    for processing.
                    If not provided, all the supported format properties (e.g.
                    fesm2015, fesm5, es2015, esm2015, esm5, main, module) in the
                    package.json are considered.                         [array]
  -t, --target      A relative path (from the `source` path) to a single
                    entry-point to process (plus its dependencies).
  --first-only      If specified then only the first matching package.json
                    property will be compiled.                         [boolean]
  -l, --loglevel    The lowest severity logging message that should be output.
                                     [choices: "debug", "info", "warn", "error"]
  --help            Show help                                          [boolean]

Ah, thanks @alan-agius4. So what would be the recommended way to build a library against ivy?

If you are using the CLI or @ngtools/webpack, you don't need to do anything, as the NGCC is called during TS module resolutions in @ngtools/webpack.

If you don't use the CLI. You can simply run npx ivy-ngcc as a postinstall hook. (No need to specify any addition parameters.)

For libraries with Ivy, during development you choose to build the library with ngtsc (Ivy) so you don't have the overhead of NGCC, however for production you should still ship the library with VE code.

So for Ionic, if we wanted to build the library against ivy, we can still use ngc to build and things will work fine?

Yeah, at the moment libraries should be built using ngc

Thanks!

If you want more details feel free to ping me on slack 😀.