Skip to content

Commit

Permalink
feat(web): replace usages of @nrwl with @nx (nrwl#16376)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz authored Apr 19, 2023
1 parent 1780aac commit 76dfc62
Show file tree
Hide file tree
Showing 119 changed files with 305 additions and 305 deletions.
2 changes: 1 addition & 1 deletion packages/js/.babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"presets": [
[
"@nrwl/js/babel",
"@nx/js/babel",
{
"useBuiltIns": "usage"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/js/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function (api: any, options: NxWebBabelPresetOptions = {}) {

const isModern = api.caller((caller) => caller?.isModern);

// This is set by `@nrwl/web:rollup` executor
// This is set by `@nx/web:rollup` executor
const isNxPackage = api.caller((caller) => caller?.isNxPackage);

const emitDecoratorMetadata = api.caller(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ describe('convert to swc', () => {

expect(
readProjectConfiguration(tree, 'tsc-lib').targets['build']['executor']
).toEqual('@nrwl/js:tsc');
).toEqual('@nx/js:tsc');

await convertToSwcGenerator(tree, { project: 'tsc-lib' });

expect(
readProjectConfiguration(tree, 'tsc-lib').targets['build']['executor']
).toEqual('@nrwl/js:swc');
).toEqual('@nx/js:swc');
expect(
tree.exists(
join(readProjectConfiguration(tree, 'tsc-lib').root, '.swcrc')
Expand Down
8 changes: 6 additions & 2 deletions packages/js/src/generators/convert-to-swc/convert-to-swc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ function updateProjectBuildTargets(
) {
for (const target of projectTargets) {
const targetConfiguration = projectConfiguration.targets[target];
if (!targetConfiguration || targetConfiguration.executor !== '@nrwl/js:tsc')
if (
!targetConfiguration ||
(targetConfiguration.executor !== '@nx/js:tsc' &&
targetConfiguration.executor !== '@nrwl/js:tsc')
)
continue;
targetConfiguration.executor = '@nrwl/js:swc';
targetConfiguration.executor = '@nx/js:swc';
}

updateProjectConfiguration(tree, projectName, projectConfiguration);
Expand Down
2 changes: 1 addition & 1 deletion packages/js/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function initGenerator(
});
}
const devDependencies = {
'@nrwl/js': nxVersion,
'@nx/js': nxVersion,
prettier: prettierVersion,
};

Expand Down
20 changes: 10 additions & 10 deletions packages/js/src/generators/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ describe('lib', () => {

const config = readProjectConfiguration(tree, 'my-lib');
expect(config.targets.build).toEqual({
executor: '@nrwl/js:tsc',
executor: '@nx/js:tsc',
options: {
assets: ['libs/my-lib/*.md'],
main: 'libs/my-lib/src/index.ts',
Expand All @@ -776,7 +776,7 @@ describe('lib', () => {

const config = readProjectConfiguration(tree, 'my-lib');
expect(config.targets.build).toEqual({
executor: '@nrwl/js:swc',
executor: '@nx/js:swc',
options: {
assets: ['libs/my-lib/*.md'],
main: 'libs/my-lib/src/index.ts',
Expand Down Expand Up @@ -830,7 +830,7 @@ describe('lib', () => {

const config = readProjectConfiguration(tree, 'my-lib');
expect(config.targets.build).toEqual({
executor: '@nrwl/js:tsc',
executor: '@nx/js:tsc',
options: {
assets: ['libs/my-lib/*.md'],
main: 'libs/my-lib/src/index.ts',
Expand All @@ -851,7 +851,7 @@ describe('lib', () => {

const config = readProjectConfiguration(tree, 'my-lib');
expect(config.targets.build).toEqual({
executor: '@nrwl/js:swc',
executor: '@nx/js:swc',
options: {
assets: ['libs/my-lib/*.md'],
main: 'libs/my-lib/src/index.ts',
Expand Down Expand Up @@ -935,7 +935,7 @@ describe('lib', () => {

const config = readProjectConfiguration(tree, 'my-lib');
expect(config.targets.build).toEqual({
executor: '@nrwl/js:tsc',
executor: '@nx/js:tsc',
options: {
assets: ['libs/my-lib/*.md'],
main: 'libs/my-lib/src/index.ts',
Expand Down Expand Up @@ -1011,7 +1011,7 @@ describe('lib', () => {
expect(tree.exists('libs/my-lib/.babelrc')).toBeFalsy();
});

it('should generate a .babelrc when flag is set to true (even if there is no `@nrwl/web` plugin installed)', async () => {
it('should generate a .babelrc when flag is set to true (even if there is no `@nx/web` plugin installed)', async () => {
updateJson(tree, 'package.json', (json) => {
json.devDependencies = {};
return json;
Expand All @@ -1030,7 +1030,7 @@ describe('lib', () => {
{
"presets": [
[
"@nrwl/js/babel",
"@nx/js/babel",
{
"useBuiltIns": "usage",
},
Expand All @@ -1040,11 +1040,11 @@ describe('lib', () => {
`);
});

it('should not generate a .babelrc when flag is not set and there is NOT a `@nrwl/web` package installed', async () => {
it('should not generate a .babelrc when flag is not set and there is NOT a `@nx/web` package installed', async () => {
updateJson(tree, 'package.json', (json) => {
json.devDependencies = {
'@nrwl/angular': '1.1.1',
'@nrwl/next': '1.1.1',
'@nx/angular': '1.1.1',
'@nx/next': '1.1.1',
};
return json;
});
Expand Down
14 changes: 7 additions & 7 deletions packages/js/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ function addBabelRc(tree: Tree, options: NormalizedSchema) {
const filename = '.babelrc';

const babelrc = {
presets: [['@nrwl/js/babel', { useBuiltIns: 'usage' }]],
presets: [['@nx/js/babel', { useBuiltIns: 'usage' }]],
};

writeJson(tree, join(options.projectRoot, filename), babelrc);
Expand Down Expand Up @@ -426,7 +426,7 @@ function normalizeOptions(
*
* In the past, the only way to get a non-buildable library was to set buildable to false.
* Now, the only way to get a non-buildble library is to set bundler to none.
* By default, with nothing provided, libraries are buildable with `@nrwl/js:tsc`.
* By default, with nothing provided, libraries are buildable with `@nx/js:tsc`.
*/

options.bundler = options.bundler ?? options.compiler ?? 'tsc';
Expand Down Expand Up @@ -534,7 +534,7 @@ function addProjectDependencies(
tree,
{},
{
'@nrwl/esbuild': nxVersion,
'@nx/esbuild': nxVersion,
'@types/node': typesNodeVersion,
esbuild: esbuildVersion,
}
Expand All @@ -558,14 +558,14 @@ function addProjectDependencies(
function getBuildExecutor(bundler: Bundler) {
switch (bundler) {
case 'esbuild':
return `@nrwl/esbuild:esbuild`;
return `@nx/esbuild:esbuild`;
case 'rollup':
return `@nrwl/rollup:rollup`;
return `@nx/rollup:rollup`;
case 'swc':
case 'tsc':
return `@nrwl/js:${bundler}`;
return `@nx/js:${bundler}`;
case 'vite':
return `@nrwl/vite:build`;
return `@nx/vite:build`;
case 'none':
default:
return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ async function setup(tree: Tree) {
});

const projectConfig = readProjectConfiguration(tree, 'my-lib');
projectConfig.targets.build.executor = '@nrwl/js:swc';
projectConfig.targets.test.executor = '@nrwl/jest:jest';
updateProjectConfiguration(tree, 'my-lib', projectConfig);

Expand Down
4 changes: 2 additions & 2 deletions packages/js/src/utils/compiler-helper-dependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export enum HelperDependency {
}

const jsExecutors = {
'@nrwl/js:tsc': {
'@nx/js:tsc': {
helperDependency: HelperDependency.tsc,
getConfigPath: (options: ExecutorOptions, contextRoot: string, _: string) =>
join(contextRoot, options.tsConfig),
} as const,
'@nrwl/js:swc': {
'@nx/js:swc': {
helperDependency: HelperDependency.swc,
getConfigPath: (
options: SwcExecutorOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/js/src/utils/minimal-publish-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const publishScriptContent = `
* You might need to authenticate with NPM before running this script.
*/
import { readCachedProjectGraph } from '@nrwl/devkit';
import { readCachedProjectGraph } from '@nx/devkit';
import { execSync } from 'child_process';
import { readFileSync, writeFileSync } from 'fs';
import chalk from 'chalk';
Expand Down
2 changes: 1 addition & 1 deletion packages/next/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"rules": {
"no-restricted-imports": [
"error",
"@nrwl/workspace",
"@nx/workspace",
"@angular-devkit/core",
"@angular-devkit/schematics",
"@angular-devkit/architect"
Expand Down
2 changes: 1 addition & 1 deletion packages/next/generators.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nx/next",
"version": "0.1",
"extends": ["@nrwl/react"],
"extends": ["@nx/react"],
"schematics": {
"init": {
"factory": "./src/generators/init/init#nextInitSchematic",
Expand Down
12 changes: 10 additions & 2 deletions packages/next/plugins/with-nx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ function getNxContext(
} {
const targetConfig = getTargetConfig(graph, target);

if ('@nrwl/next:build' === targetConfig.executor) {
if (
'@nx/next:build' === targetConfig.executor ||
'@nrwl/next:build' === targetConfig.executor
) {
return {
node: graph.nodes[target.project],
options: getOptions(graph, target),
Expand All @@ -101,7 +104,12 @@ function getNxContext(

return getNxContext(graph, devServerTarget);
} else if (
['@nrwl/next:server', '@nrwl/next:export'].includes(targetConfig.executor)
[
'@nx/next:server',
'@nx/next:export',
'@nrwl/next:server',
'@nrwl/next:export',
].includes(targetConfig.executor)
) {
const buildTarget = parseTargetString(targetOptions.buildTarget, graph);
return getNxContext(graph, buildTarget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ exports[`app --style styled-jsx should use <style jsx> in index page 1`] = `
</summary>
<pre>
<span># Generate UI lib</span>
nx g @nrwl/next:library ui
nx g @nx/next:library ui
<span># Add a component</span>
nx g @nrwl/next:component button --project=ui
nx g @nx/next:component button --project=ui
</pre>
</details>
<details>
Expand Down
10 changes: 5 additions & 5 deletions packages/next/src/generators/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ describe('app', () => {
});

expect(tree.read('apps/my-app/jest.config.ts', 'utf-8')).toContain(
`'^(?!.*\\\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest'`
`'^(?!.*\\\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest'`
);
});

Expand All @@ -236,7 +236,7 @@ describe('app', () => {

const projectConfiguration = readProjectConfiguration(tree, 'my-app');
expect(projectConfiguration.targets.build.executor).toEqual(
'@nrwl/next:build'
'@nx/next:build'
);
expect(projectConfiguration.targets.build.options).toEqual({
root: 'apps/my-app',
Expand All @@ -252,7 +252,7 @@ describe('app', () => {

const projectConfiguration = readProjectConfiguration(tree, 'my-app');
expect(projectConfiguration.targets.serve.executor).toEqual(
'@nrwl/next:server'
'@nx/next:server'
);
expect(projectConfiguration.targets.serve.options).toEqual({
buildTarget: 'my-app:build',
Expand All @@ -275,7 +275,7 @@ describe('app', () => {

const projectConfiguration = readProjectConfiguration(tree, 'my-app');
expect(projectConfiguration.targets.export.executor).toEqual(
'@nrwl/next:export'
'@nx/next:export'
);
expect(projectConfiguration.targets.export.options).toEqual({
buildTarget: 'my-app:build:production',
Expand Down Expand Up @@ -339,7 +339,7 @@ describe('app', () => {
"jest": true,
},
"extends": [
"plugin:@nrwl/nx/react-typescript",
"plugin:@nx/nx/react-typescript",
"next",
"next/core-web-vitals",
"../../.eslintrc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"presets": [
<% if (style === '@emotion/styled') { %>
[
"@nrwl/next/babel",
"@nx/next/babel",
{
"preset-react": {
"runtime": "automatic",
Expand All @@ -11,7 +11,7 @@
}
]
<% } else { %>
"@nrwl/next/babel"
"@nx/next/babel"
<% } %>
],
"plugins": [
Expand Down
Loading

0 comments on commit 76dfc62

Please sign in to comment.