nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.52k stars 2.34k forks source link

@nrwl/workspace:move fails on tsconfig.json with comments #13740

Closed Den-dp closed 1 year ago

Den-dp commented 1 year ago

Current Behavior

@nrwl/workspace:move generator fails while trying to move around a lib in a newly created (via angular cli) project, since from the start tsconfig.json has comments inside (I guess it affects all newcomers trying to use nx in their projects).

Expected Behavior

npx nx generate @nrwl/workspace:move libs --project-name=some-lib --verbose

should work with tsconfig.json which uses json5 file format (comments).

Github Repo

No response

Steps to Reproduce

  1. ng new ng14-minimal --minimal --inline-style --inline-template --skip-tests --routing false --style=css
  2. cd ng14-minimal
  3. ng g library some-lib
  4. cat tsconfig.json
    /* To learn more about this file see: https://angular.io/config/tsconfig. */
    {
    "compileOnSave": false,
  5. npm i @nrwl/workspace -D
  6. npx nx generate @nrwl/workspace:move libs --project-name=some-lib --verbose

Nx Report

>  NX   Report complete - copy this into the issue template

   Node : 14.20.0
   OS   : win32 x64
   npm  : 6.14.17

   nx : 15.3.0
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.3.0
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : Not Found
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : Not Found
   @nrwl/js : Not Found
   @nrwl/linter : 15.3.0
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/webpack : Not Found
   @nrwl/workspace : 15.3.0
   typescript : 4.7.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:

Failure Logs

npx nx generate @nrwl/workspace:move libs --project-name=some-lib --verbose

>  NX  Generating @nrwl/workspace:move

 >  NX   Unexpected token / in JSON at position 0

SyntaxError: Unexpected token / in JSON at position 0
    at JSON.parse (<anonymous>)
    at updateImports (C:\temp\ng14-minimal\node_modules\@nrwl\workspace\src\generators\move\lib\update-imports.js:29:25)
    at C:\temp\ng14-minimal\node_modules\@nrwl\workspace\src\generators\move\move.js:28:44
    at Generator.next (<anonymous>)
    at C:\temp\ng14-minimal\node_modules\tslib\tslib.js:118:75
    at new Promise (<anonymous>)
    at Object.__awaiter (C:\temp\ng14-minimal\node_modules\tslib\tslib.js:114:16)
    at moveGenerator (C:\temp\ng14-minimal\node_modules\@nrwl\workspace\src\generators\move\move.js:22:20)
    at Object.<anonymous> (C:\temp\ng14-minimal\node_modules\nx\src\command-line\generate.js:222:36)
    at Generator.next (<anonymous>)

Additional Information

No response

Coly010 commented 1 year ago

There's a specific move generator for Angular workspaces

nx g @nrwl/angular:move

Can you try that instead? https://nx.dev/packages/angular/generators/move

Den-dp commented 1 year ago

@Coly010 unfortunately I see the same error

image

looks like internally it uses @nrwl/workspace:move anyway https://github.com/nrwl/nx/blob/c3c9b2d24d384ce1b39d78461eb86c7c0c84bb75/packages/angular/src/generators/move/move.ts#L1-L25

Coly010 commented 1 year ago

It does, but it does extra things required for angular, let me take a look

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.