238 Commits

Author SHA1 Message Date
Leosvel Pérez Espinosa
2b820a274e
docs(misc): update /packages/ links to /nx-api/ (#26128)
- Update `/packages/` links to `/nx-api/`
- Convert some unneeded absolute links to relative
- Remove leftover examples doc for the already removed `cypress-project`
generator

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #26126
2024-05-28 09:44:48 -04:00
Nicholas Cunningham
6292055aba
feat(webpack): Support incremental builds via buildLibsFromSource (#25060)
This PR adds the ability for incremental builds when using the Webpack
Plugin.

Instead of using the source library directly, you can now utilize the
output folder by utilizing the `buildLibsFromSource` option within your
webpack.config file, through `NxAppWebpackPlugin`. This means that
instead of accessing `mylib/src/index.ts`, it will access
`dist/mylib/index.js`.

This directly aligns with incremental builds as it ensures that the
build process only recompiles the source doe that has been modified
since the last build.
2024-05-27 14:04:15 -04:00
Craigory Coppola
a4a185f45b
fix(misc): various inference plugins caching should track changes (#23315)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
Plugin's cache entries overwrite each other if multiple instances of the
same plugin are running. They also don't remember previous cache states.

## Expected Behavior
Plugin's caches grow as changes are made, and don't overwrite previous
entries.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-05-23 17:05:05 -04:00
Jason Jean
7705757c62
fix(misc): adjust npm keywords (#24743)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->

NPM Keywords do not include those which are shown under the categories
under the `Discover packages` section. https://www.npmjs.com/

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

NPM Keywords include those which are shown under the categories under
the `Discover packages` section when applicable. https://www.npmjs.com/


![image](https://github.com/nrwl/nx/assets/8104246/ebbd4317-0336-4834-b4eb-0c673a358601)


## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-05-22 22:30:10 -04:00
Colum Ferry
504d0482fa
fix(webpack): only add entrypoints if they are intentionally injected #20049 (#23444)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->
We are still injecting `styles` and `scripts` even if `inject=false` in
`project.json`.


## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Do not inject styles and scripts if `inject=false`

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #20049
2024-05-16 12:48:14 -04:00
Jason Jean
cfadd7d8cf
Revert "fix(core): addPlugin should not conflict on project.json targ… (#23391)
…ets (#23264)"

This reverts commit 85c89160

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-05-14 18:01:30 -04:00
Colum Ferry
3e8496721d
fix(webpack): apply-base-config should initialize options it will set #23296 (#23368)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->
The `@nx/webpack/plugin` will resolve and read webpack options from user
defined config files.
However, it does not set the env vars indicating that a task is being
run, because tasks are not being run at this stage.

This means that certain config properties are not being set by
`applyBaseConfig`.

Users' webpack configs may rely on these properties being set so they
can modify them.
When not set, this throws, meaning the graph cannot be constructed.


## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Initialize the properties that we usually set when `applyBaseConfig` is
used.


## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #23296
2024-05-14 14:19:47 +01:00
Colum Ferry
85c8916087
fix(core): addPlugin should not conflict on project.json targets (#23264)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->
Calculating conflicts in target names does not consider if the
project.json defined targets will actually be impacted by the plugin
that wants to be added creating false negatives

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Calculating conflicts should be more accurate

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #22476
2024-05-13 10:53:09 -04:00
Edward Wang
8f25ade650
fix(webpack): publicPath and rebaseRootRelative (#20992)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->
 can not configure webpack publicPath with NX option.
## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
 make the publicPath work with postcssCliResources.
## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #

---------

Co-authored-by: Colum Ferry <cferry09@gmail.com>
2024-05-09 12:39:29 +01:00
Jason Jean
8f705e31e2
fix(misc): adjust deprecation messages to v20 (#23223)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Breaking Changes:


BREAKING CHANGE: `nx print-affected` was deprecated in 16.4.0 and has
been removed.
BREAKING CHANGE: `nx affected:graph` was deprecated in 16.4.0 and has
been removed.
BREAKING CHANGE: The `criticalPath` and `affectedProjects` properties of
the JSON created by `nx graph --file graph.json` was deprecated in
16.2.0 and has been removed.

## Current Behavior
<!-- This is the behavior we have today -->

Some deprecation messages still reference v19.

`nx print-affected` was deprecated in 16.4.0 to be removed in Nx 19 but
was not removed.
`nx affected:graph` was deprecated in 16.4.0 to be removed in Nx 19 but
was not removed.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

Deprecation messages reference v20 now.

`nx print-affected` is removed.
`nx affected:graph` is removed.

There are redirects to a `deprecated` page describing those commands for
Nx users using Nx <19

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-05-08 21:54:41 -04:00
Mike Peters
1449d1acc1
fix(webpack): don't overwrite output config (#22116)
## Current Behavior

Some webpack output options, like `filename` are overwritten when using
the `NxWebpackPlugin`, e.g.

```ts
module.exports = {
  output: {
    path: join(__dirname, '../../dist/apps/my-app'),
    // this has no affect:
    filename: ({ runtime }) =>
      migrationEntryPoints.some(({ entryName }) => entryName === runtime)
        ? 'migrations/[name].js'
        : '[name].js',
  },
  plugins: [
    new NxWebpackPlugin({ ... }),
  ]
};
```

## Expected Behavior

The `NxWebpackPlugin` should preserve base config where it makes sense.

I think this is the intended behaviour, but required some extra
parentheses to behave correctly.
2024-05-08 14:12:08 +00:00
Mateo Tibaquirá
7dd7c2bab8
fix(webpack): fix default compiler option (#22762)
Given a configuration without `options.tsConfig` the `babel` compiler
breaks in `createLoaderFromCompiler` where the babel case uses
`path.join(options.root, options.tsConfig)` and throws an exception if
it's undefined.

## Current Behavior


In my case, the root `package.json` generates a dependency in the tree
with "empty" options:
```
{
  root: '/root/of/my/monorepo/monorepo',
  projectRoot: '',
  sourceRoot: '',
  outputFileName: undefined,
  outputPath: undefined,
  assets: [],
  target: 'web',
  projectName: undefined,
  targetName: undefined,
  configurationName: undefined,
  projectGraph: undefined
}
``` 
which breaks the project graph with this exception:
```
Unable to read angular.json
[Failed to process project graph.
  The "@nx/webpack/plugin" plugin threw an error while creating nodes from src/backend/server/webpack.config.js:
    TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
        at new NodeError (node:internal/errors:405:5)
        at validateString (node:internal/validators:162:11)
        at Object.join (node:path:1171:7)
        at createLoaderFromCompiler (/monorepo/node_modules/.pnpm/@nx+webpack@18.2.2_@swc-node+register@1.9.0_@swc+core@1.3.107_@types+node@18.16.9_nx@18.2.2_t_auhl3zn4afi4laot7gdsrcezcy/node_modules/@nx/webpack/src/plugins/nx-webpack-plugin/lib/compiler-loaders.js:50:58)
        at applyNxDependentConfig (/monorepo/node_modules/.pnpm/@nx+webpack@18.2.2_@swc-node+register@1.9.0_@swc+core@1.3.107_@types+node@18.16.9_nx@18.2.2_t_auhl3zn4afi4laot7gdsrcezcy/node_modules/@nx/webpack/src/plugins/nx-webpack-plugin/lib/apply-base-config.js:314:61)
        at applyBaseConfig (/monorepo/node_modules/.pnpm/@nx+webpack@18.2.2_@swc-node+register@1.9.0_@swc+core@1.3.107_@types+node@18.16.9_nx@18.2.2_t_auhl3zn4afi4laot7gdsrcezcy/node_modules/@nx/webpack/src/plugins/nx-webpack-plugin/lib/apply-base-config.js:36:5)
        at configure (/monorepo/node_modules/.pnpm/@nx+webpack@18.2.2_@swc-node+register@1.9.0_@swc+core@1.3.107_@types+node@18.16.9_nx@18.2.2_t_auhl3zn4afi4laot7gdsrcezcy/node_modules/@nx/webpack/src/utils/with-nx.js:15:49)
        at combined (/monorepo/node_modules/.pnpm/@nx+webpack@18.2.2_@swc-node+register@1.9.0_@swc+core@1.3.107_@types+node@18.16.9_nx@18.2.2_t_auhl3zn4afi4laot7gdsrcezcy/node_modules/@nx/webpack/src/utils/config.js:23:28)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async readWebpackOptions (/monorepo/node_modules/.pnpm/@nx+webpack@18.2.2_@swc-node+register@1.9.0_@swc+core@1.3.107_@types+node@18.16.9_nx@18.2.2_t_auhl3zn4afi4laot7gdsrcezcy/node_modules/@nx/webpack/src/utils/webpack/read-webpack-options.js:17:18)] {
  name: 'ProjectGraphError'
}
```

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

The default values should fallback properly without throwing an
exception for this case.

---------

Co-authored-by: Colum Ferry <cferry09@gmail.com>
2024-05-08 13:16:26 +01:00
Colum Ferry
bf90604180
fix(module-federation): nested projects should be ordered first when reading from tsconfig paths #20284 (#23212)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->
When using nested projects (note: not secondary entry points), the
`shareWorkspaceLibraries` needs to order the nested projects first for
webpack to resolve the import path aliases correctly.


## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Ensure nested projects are ordered first when reading tsconfig path
aliases

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #20284
2024-05-07 09:57:09 -04:00
Jason Jean
2cb62c6177
chore(repo): update nx to 19.0.0-beta.11 (#23133)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->

This repo is using Nx `19.0.0-beta.8`

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

This repo is using Nx `19.0.0-beta.11`

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-05-03 10:21:26 -04:00
Jack Hsu
2e621f324c
feat(misc): v19 cleanup for Nx plugins (#23104)
This PR removes deprecated code that's been slated for removal in Nx 19
- mentioned as `TODO(v19)` comments.

## Breaking Changes

- **CNW:** `create-nx-workspace` no longer support `--preset=empty` and
`--preset=core`, use `--preset=apps` and `--preset=npm` respectively.
Deprecated in Nx 15.9.
- **Next.js:** `NX_` environment variables are no longer bundled into
Next.js apps, use `NEXT_PUBLIC` instead. Deprecated in Nx 16.8.
- **Webpack, Storybook, Esbuild:** `NX_` environment variables are no
longer bundled into browser bundles, use `NX_PUBLIC` instead. This
removes the possibility of intentional bundling of `NX_` variables.
Deprecated in Nx 18.
- **Cypress:** `cypressComponentConfiguration` generator removed from
`@nx/cypress`, use `configurationGenerator`instead. Deprecated in Nx
16.8.
- **Cypress:** `cypressProjectGenerator` generator removed from
`@nx/cypress`, use `configurationGenerator` instead. Deprecated in Nx
15.9.
- **Expo:** `withNxWebpack` removed from `@nx/expo`, use [metro
bundler](https://docs.expo.dev/guides/customizing-metro/)
(https://docs.expo.dev/guides/customizing-metro/) in app.json instead.
There is a migration to handle this in Nx 19. Deprecated in Nx 15.8.

## Deferred to v20

- **JS:** `classProperties.loose` option removed from `@nx/js/babel`
preset, use `loose` instead. Deprecated in Nx 17.0.
- **ESLint:** Low priority task to "deviations from
@typescript-eslint/recommended" for our lint rules. @JamesHenry will
look at this later before Nx 20, but it is unimportant.
- **React:** component testing does not work with Project Crystal, and
we need the executor + built-in webpack configs to run CT. Will do a
follow-up on this after Nx 19 release. Related issue:
https://github.com/nrwl/nx/issues/21546
- **Next.js:** `withStylus` removal from `@nx/next`, use SASS instead.
It hasn't worked, but we kept the file to throw an error when used.
Deprecated in Nx 17.0.
- **Next.js**: `@nx/next:component` and `@nx/next:page` generators to
not derive the `components` and `app`/`pages` directory. Use `nx g
@nx/next:component apps/myapp/components/button` instead. Deprecated in
Nx 17.0.
- **Webpack:** `isolatedConfig` option removal from
`@nx/webpack:webpack` executor. There is a migration to handle this in
Nx 19. Deprecated in in Nx 17.2.
- **Angular:** `executeWebpackDevServerBuilder` removal from
`@nx/angular/executors`, use `executeDevServerBuilder` instead.
Deprecated in Nx 17.0.
2024-05-02 13:37:12 -04:00
Jason Jean
a64a7e2db9
feat(core): cleanup for v19 (#22993) 2024-05-01 12:12:32 -04:00
Jack Hsu
b8e6ebbf9a
feat(webpack): change plugin import paths to speed up config loading (#23021) 2024-04-26 10:41:59 -04:00
Colum Ferry
a78e75ccab
fix(webpack): should correctly normalize paths in NxWebpackPlugin (#23003) 2024-04-26 12:55:07 +01:00
Jack Hsu
bc43243498
chore(repo): add eslint and jest plugins to use inferred targets (#22946) 2024-04-23 21:52:13 -04:00
Craigory Coppola
80b55144db
fix(misc): don't clear node_modules require cache (#22907) 2024-04-19 17:41:20 -04:00
Jason Jean
bf206e578e
feat(misc): non conflicting init/add flow (#22791) 2024-04-15 16:45:08 -04:00
Nicholas Cunningham
c27a668530
fix(webpack): Should work when absolute paths are supplied as output (#22736) 2024-04-09 09:27:10 -06:00
Nicholas Cunningham
f11d7be115
fix(webpack): typo for outputPath (#22734) 2024-04-09 09:11:46 -06:00
Jack Hsu
900db73c1d
fix(webpack): remove url-loader from dependencies since it is replaced by asset modules (#22698) 2024-04-05 13:49:32 -04:00
Colum Ferry
640c61dd1a
fix(module-federation): serve dynamic remotes statically in their own processes (#22688) 2024-04-05 11:58:32 -04:00
Jack Hsu
4fdf862700
fix(webpack): support standard webpack config with @nx/webpack:dev-server (#22660) 2024-04-03 15:37:05 -06:00
Jack Hsu
7d2a42027c
fix(webpack): resolve assets from executor options as relative to workspace root (#22544) 2024-03-27 21:36:19 -04:00
Jack Hsu
35321615b2
fix(webpack): pass options from executor to NxWebpackPlugin correctly (#22529) 2024-03-27 08:21:04 -04:00
Colum Ferry
29c80a33de
fix(web): spa flag should correctly define redirect (#22487) 2024-03-26 16:51:03 +00:00
Jack Hsu
b7ffb257a2
fix(bundling): prevent sensitive keys from being bundled (#22413) 2024-03-20 13:01:43 -04:00
Nicholas Cunningham
55f31cf07b
fix(webpack): Stylus loader path (#22373) 2024-03-18 10:25:00 -06:00
James Henry
1fe5b98f45
fix(linter): refactor pcv3 plugin, expose configFiles on context (#21677) 2024-03-15 16:29:13 -04:00
Craigory Coppola
a89c73483e
feat(core): use flag in nx.json for toggling crystal (#21980) 2024-02-29 15:18:46 -05:00
Dan Roujinsky
4a5b5f245d
fix(webpack): correctly handle paranthesis in PostCSS in url (#21884) 2024-02-20 16:02:56 +02:00
Emily Xiong
4be897ac3f
fix(webpack): resolve relative path for assets inputs (#21822) 2024-02-15 13:42:25 -05:00
Colum Ferry
448a83a116
fix(angular): ajv hoisting issue (#21641) 2024-02-06 21:21:12 +04:00
Jack Hsu
bf62661bb9
fix(webpack): require ForkTsCheckerWebpackPlugin only as required (#21629) 2024-02-05 18:04:39 -05:00
Jack Hsu
e85f700f52
fix(webpack): fix webpack plugin issues and e2e tests (#21531) 2024-02-02 11:27:40 -05:00
Jason Jean
396ffc4636
feat(core): enable project crystal by default (#21403)
Co-authored-by: Katerina Skroumpelou <sk.katherine@gmail.com>
Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
Co-authored-by: Colum Ferry <cferry09@gmail.com>
Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
Co-authored-by: Emily Xiong <xiongemi@gmail.com>
Co-authored-by: Nicholas Cunningham <ndcunningham@gmail.com>
2024-02-02 03:40:59 -05:00
Colum Ferry
fbca31ac37
fix(module-federation): ensure incorrect tsconfig path mappings are not used #21391 (#21416) 2024-01-31 17:06:58 +00:00
andreasmoller25
ecddfe1065
fix(webpack): correctly handle data URIs with escaped quotes in style… (#20988) 2024-01-31 18:47:31 +02:00
Craigory Coppola
deb0f1a492
chore(repo): bump deprecation messages to v19 (#21430) 2024-01-30 16:29:05 -05:00
Dmitry Zakharov
8ee8f3ffc3
chore(repo): bump @babel/core plugin-transform-runtime to 7.23.2 (#20952) 2024-01-30 13:50:29 -05:00
beeman
a9974d3f25
docs(misc): change http:// to https:// (#19534) 2024-01-30 11:33:13 -05:00
Jack Hsu
89c5188df3
feat(webpack): simplify inferred webpack-cli command (#21340) 2024-01-26 12:00:18 -05:00
Leosvel Pérez Espinosa
e4758358b0
feat(misc): optionally update package.json scripts in init generators (#21204) 2024-01-22 13:51:41 -05:00
Jason Jean
1ffd6731dc
feat(core): add target defaults in configuration generators rather th… (#21105) 2024-01-17 16:02:47 -05:00
Emily Xiong
6141f44203
feat(core): add keepExistingVersions to all packages (#21169) 2024-01-17 14:22:58 -05:00
Leosvel Pérez Espinosa
047dc22aed
cleanup(misc): clean up init generators (#21088) 2024-01-16 15:29:44 +01:00
Emily Xiong
633dcfba00
bugfix(webpack): merge alias webpack (#21098) 2024-01-12 10:47:31 -05:00