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

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

Closed
Den-dp opened this issue Dec 9, 2022 · 4 comments · Fixed by #13866
Closed

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

Den-dp opened this issue Dec 9, 2022 · 4 comments · Fixed by #13866
Labels
blocked: retry with latest Retry with latest release or head. outdated scope: angular Issues related to Angular support in Nx scope: misc Misc issues type: bug

Comments

@Den-dp
Copy link

Den-dp commented Dec 9, 2022

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,
  1. npm i @nrwl/workspace -D
  2. 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

@AgentEnder AgentEnder added scope: angular Issues related to Angular support in Nx scope: misc Misc issues labels Dec 13, 2022
@Coly010
Copy link
Contributor

Coly010 commented Dec 14, 2022

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

@Coly010 Coly010 added the blocked: retry with latest Retry with latest release or head. label Dec 14, 2022
@Den-dp
Copy link
Author

Den-dp commented Dec 15, 2022

@Coly010 unfortunately I see the same error

image

looks like internally it uses @nrwl/workspace:move anyway

import { convertNxGenerator, formatFiles, Tree } from '@nrwl/devkit';
import { moveGenerator } from '@nrwl/workspace/generators';
import { updateModuleName } from './lib/update-module-name';
import { updateNgPackage } from './lib/update-ng-package';
import { Schema } from './schema';
/**
* Moves an Angular lib/app to another folder (and renames it in the process)
*
* @remarks It's important to note that `updateModuleName` is done after the update
* to the workspace, so it can't use the same tricks as the `@nrwl/workspace` rules
* to get the before and after names and paths.
*/
export async function angularMoveGenerator(
tree: Tree,
schema: Schema
): Promise<void> {
await moveGenerator(tree, { ...schema, skipFormat: true });
updateModuleName(tree, schema);
updateNgPackage(tree, schema);
if (!schema.skipFormat) {
await formatFiles(tree);
}
}

@Coly010
Copy link
Contributor

Coly010 commented Dec 15, 2022

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

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: retry with latest Retry with latest release or head. outdated scope: angular Issues related to Angular support in Nx scope: misc Misc issues type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants