Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

22
node_modules/@nx/react/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2017-2026 Narwhal Technologies Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

68
node_modules/@nx/react/README.md generated vendored Normal file
View File

@@ -0,0 +1,68 @@
<p style="text-align: center;">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
<img alt="Nx - Smart Monorepos · Fast Builds" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
</picture>
</p>
<div style="text-align: center;">
[![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
[![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)]()
[![NPM Version](https://badge.fury.io/js/nx.svg)](https://www.npmjs.com/package/nx)
[![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]()
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Join us on the Official Nx Discord Server](https://img.shields.io/discord/1143497901675401286?label=discord)](https://go.nx.dev/community)
</div>
<hr>
# Nx: Smart Monorepos · Fast Builds
Get to green PRs in half the time. Nx optimizes your builds, scales your CI, and fixes failed PRs. Built for developers and AI agents.
This package is a [React plugin for Nx](https://nx.dev/nx-api/react).
## Getting Started
### Creating an Nx Workspace
**Using `npx`**
```bash
npx create-nx-workspace
```
**Using `npm init`**
```bash
npm init nx-workspace
```
**Using `yarn create`**
```bash
yarn create nx-workspace
```
### Adding Nx to an Existing Repository
Run:
```bash
npx nx@latest init
```
## Documentation & Resources
- [Nx.Dev: Documentation, Guides, Tutorials](https://nx.dev)
- [Intro to Nx](https://nx.dev/getting-started/intro)
- [Official Nx YouTube Channel](https://www.youtube.com/@NxDevtools)
- [Blog Posts About Nx](https://nx.dev/blog)
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
width="100%" alt="Nx - Smart Monorepos · Fast Builds"></a></p>

2
node_modules/@nx/react/ast-utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export { findMainRenderStatement, findComponentImportPath, findElements, findDefaultExport, findClosestOpening, isTag, } from './src/utils/ast-utils';
//# sourceMappingURL=ast-utils.d.ts.map

1
node_modules/@nx/react/ast-utils.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"ast-utils.d.ts","sourceRoot":"","sources":["../../../packages/react/ast-utils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,GACN,MAAM,uBAAuB,CAAC"}

11
node_modules/@nx/react/ast-utils.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isTag = exports.findClosestOpening = exports.findDefaultExport = exports.findElements = exports.findComponentImportPath = exports.findMainRenderStatement = void 0;
// Exported schematics development outside of Nx. e.g. workspace schematics
var ast_utils_1 = require("./src/utils/ast-utils");
Object.defineProperty(exports, "findMainRenderStatement", { enumerable: true, get: function () { return ast_utils_1.findMainRenderStatement; } });
Object.defineProperty(exports, "findComponentImportPath", { enumerable: true, get: function () { return ast_utils_1.findComponentImportPath; } });
Object.defineProperty(exports, "findElements", { enumerable: true, get: function () { return ast_utils_1.findElements; } });
Object.defineProperty(exports, "findDefaultExport", { enumerable: true, get: function () { return ast_utils_1.findDefaultExport; } });
Object.defineProperty(exports, "findClosestOpening", { enumerable: true, get: function () { return ast_utils_1.findClosestOpening; } });
Object.defineProperty(exports, "isTag", { enumerable: true, get: function () { return ast_utils_1.isTag; } });

25
node_modules/@nx/react/babel.d.ts generated vendored Normal file
View File

@@ -0,0 +1,25 @@
interface NxReactBabelOptions {
decorators?: {
decoratorsBeforeExport?: boolean;
legacy?: boolean;
};
development?: boolean;
importSource?: string;
loose?: boolean;
reactCompiler?: boolean | {
compilationMode?: string;
sources?: (filename: string) => boolean;
};
runtime?: string;
useBuiltIns?: boolean | string;
/** @deprecated Use `loose` option instead of `classProperties.loose`
*/
classProperties?: {
loose?: boolean;
};
}
declare function getReactPresetOptions({ presetOptions, env, }: {
env: string;
presetOptions: NxReactBabelOptions;
}): Record<string, string | boolean>;
//# sourceMappingURL=babel.d.ts.map

1
node_modules/@nx/react/babel.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"babel.d.ts","sourceRoot":"","sources":["../../../packages/react/babel.ts"],"names":[],"mappings":"AAIA,UAAU,mBAAmB;IAC3B,UAAU,CAAC,EAAE;QACX,sBAAsB,CAAC,EAAE,OAAO,CAAC;QACjC,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EACV,OAAO,GACP;QACE,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;KACzC,CAAC;IACN,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC/B;OACG;IACH,eAAe,CAAC,EAAE;QAChB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,CAAC;CACH;AA0DD,iBAAS,qBAAqB,CAAC,EAC7B,aAAa,EACb,GAAG,GACJ,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,mBAAmB,CAAC;CACpC,oCAiBA"}

66
node_modules/@nx/react/babel.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
/*
* Babel preset to provide React support for Nx.
*/
module.exports = function (api, options) {
api.assertVersion(7);
const env = api.env();
/**
* pagesDir is set when being transpiled by Next.js
*/
const isNextJs = api.caller((caller) => caller?.pagesDir);
const presets = [
[require.resolve('@nx/js/babel'), options],
];
const plugins = [];
/**
* Next.js already includes the preset-react, and including it
* the second time here results in having two instances of this preset.
*
* The plugin is duplicated as opposed to being merged because Next.js uses
* their own compiled version of the plugin, rather than one from node_modules.
* That affectively changes the "identity" of the plugin, and babel treats it as
* two separate instances.
*
* More on babel merging: https://babeljs.io/docs/en/options#merging
*/
if (!isNextJs) {
presets.push([
require.resolve('@babel/preset-react'),
getReactPresetOptions({
presetOptions: options,
env,
}),
]);
}
if (options.reactCompiler) {
try {
const reactCompilerPlugin = require.resolve('babel-plugin-react-compiler');
plugins.push([
reactCompilerPlugin,
typeof options.reactCompiler !== 'boolean' ? options.reactCompiler : {},
]);
}
catch {
throw new Error(`Could not find "babel-plugin-react-compiler". Did you install it?`);
}
}
return {
presets,
plugins,
};
};
function getReactPresetOptions({ presetOptions, env, }) {
const reactPresetOptions = {
runtime: presetOptions.runtime ?? 'automatic',
development: presetOptions.development ?? env !== 'production',
};
// JSX spread is transformed into object spread in `@babel/plugin-transform-react-jsx`
// `useBuiltIns` will be removed in Babel 8.
if (reactPresetOptions.runtime === 'automatic') {
reactPresetOptions.useBuiltIns = true;
}
if (presetOptions.importSource) {
reactPresetOptions.importSource = presetOptions.importSource;
}
return reactPresetOptions;
}

19
node_modules/@nx/react/executors.json generated vendored Normal file
View File

@@ -0,0 +1,19 @@
{
"executors": {
"module-federation-dev-server": {
"implementation": "./src/executors/module-federation-dev-server/module-federation-dev-server.impl",
"schema": "./src/executors/module-federation-dev-server/schema.json",
"description": "Serve a host or remote application."
},
"module-federation-ssr-dev-server": {
"implementation": "./src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl",
"schema": "./src/executors/module-federation-ssr-dev-server/schema.json",
"description": "Serve a host application along with it's known remotes."
},
"module-federation-static-server": {
"implementation": "./src/executors/module-federation-static-server/module-federation-static-server.impl",
"schema": "./src/executors/module-federation-static-server/schema.json",
"description": "Serve a host and its remotes statically."
}
}
}

109
node_modules/@nx/react/generators.json generated vendored Normal file
View File

@@ -0,0 +1,109 @@
{
"name": "Nx React",
"version": "0.1",
"extends": ["@nx/workspace"],
"generators": {
"init": {
"factory": "./src/generators/init/init#reactInitGenerator",
"schema": "./src/generators/init/schema.json",
"description": "Initialize the `@nx/react` plugin.",
"aliases": ["ng-add"],
"hidden": true
},
"application": {
"factory": "./src/generators/application/application#applicationGeneratorInternal",
"schema": "./src/generators/application/schema.json",
"aliases": ["app"],
"x-type": "application",
"description": "Create a React application."
},
"library": {
"factory": "./src/generators/library/library#libraryGeneratorInternal",
"schema": "./src/generators/library/schema.json",
"aliases": ["lib"],
"x-type": "library",
"description": "Create a React library."
},
"component": {
"factory": "./src/generators/component/component",
"schema": "./src/generators/component/schema.json",
"description": "Create a React component.",
"aliases": ["c"]
},
"redux": {
"factory": "./src/generators/redux/redux",
"schema": "./src/generators/redux/schema.json",
"description": "Create a Redux slice for a project.",
"aliases": ["slice"]
},
"storybook-configuration": {
"factory": "./src/generators/storybook-configuration/configuration#storybookConfigurationGeneratorInternal",
"schema": "./src/generators/storybook-configuration/schema.json",
"description": "Set up storybook for a React app or library.",
"hidden": false
},
"component-story": {
"factory": "./src/generators/component-story/component-story#componentStoryGenerator",
"schema": "./src/generators/component-story/schema.json",
"description": "Generate storybook story for a React component",
"hidden": false
},
"stories": {
"factory": "./src/generators/stories/stories#storiesGenerator",
"schema": "./src/generators/stories/schema.json",
"description": "Create stories/specs for all components declared in an app or library.",
"hidden": false
},
"hook": {
"factory": "./src/generators/hook/hook",
"schema": "./src/generators/hook/schema.json",
"description": "Create a hook.",
"aliases": ["c"]
},
"host": {
"factory": "./src/generators/host/host",
"schema": "./src/generators/host/schema.json",
"x-type": "application",
"description": "Generate a host react application",
"aliases": ["consumer"]
},
"remote": {
"factory": "./src/generators/remote/remote",
"schema": "./src/generators/remote/schema.json",
"x-type": "application",
"description": "Generate a remote react application",
"aliases": ["producer"]
},
"cypress-component-configuration": {
"factory": "./src/generators/cypress-component-configuration/cypress-component-configuration#cypressComponentConfigGenerator",
"schema": "./src/generators/cypress-component-configuration/schema.json",
"description": "Setup Cypress component testing for a React project",
"hidden": false
},
"component-test": {
"factory": "./src/generators/component-test/component-test#componentTestGenerator",
"schema": "./src/generators/component-test/schema.json",
"description": "Generate a Cypress component test for a React component",
"hidden": false
},
"setup-tailwind": {
"factory": "./src/generators/setup-tailwind/setup-tailwind#setupTailwindGenerator",
"schema": "./src/generators/setup-tailwind/schema.json",
"description": "Set up Tailwind configuration for a project.",
"hidden": false,
"x-deprecated": "Generating Tailwind configuration is no longer maintained. This generator will be removed in Nx 23."
},
"setup-ssr": {
"factory": "./src/generators/setup-ssr/setup-ssr#setupSsrGenerator",
"schema": "./src/generators/setup-ssr/schema.json",
"description": "Set up SSR configuration for a project.",
"hidden": false
},
"federate-module": {
"factory": "./src/generators/federate-module/federate-module#federateModuleGenerator",
"schema": "./src/generators/federate-module/schema.json",
"description": "Federate a module.",
"hidden": false
}
}
}

24
node_modules/@nx/react/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import { NxReactWebpackPlugin as _NxReactWebpackPlugin } from './plugins/nx-react-webpack-plugin/nx-react-webpack-plugin';
/** @deprecated Use '@nx/react/webpack-plugin' instead, which can improve graph creation by 150-200ms per file. */
export declare const NxReactWebpackPlugin: typeof _NxReactWebpackPlugin;
export { extraEslintDependencies, extendReactEslintJson, } from './src/utils/lint';
export { cssInJsDependenciesBabel } from './src/utils/styled';
export { assertValidStyle } from './src/utils/assertion';
export { reactDomVersion, reactVersion } from './src/utils/versions';
export { applicationGenerator } from './src/generators/application/application';
export { componentGenerator } from './src/generators/component/component';
export { hookGenerator } from './src/generators/hook/hook';
export { componentStoryGenerator } from './src/generators/component-story/component-story';
export { libraryGenerator } from './src/generators/library/library';
export { reactInitGenerator } from './src/generators/init/init';
export { reduxGenerator } from './src/generators/redux/redux';
export { storiesGenerator } from './src/generators/stories/stories';
export { storybookConfigurationGenerator } from './src/generators/storybook-configuration/configuration';
export { hostGenerator } from './src/generators/host/host';
export { remoteGenerator } from './src/generators/remote/remote';
export { cypressComponentConfigGenerator } from './src/generators/cypress-component-configuration/cypress-component-configuration';
export { componentTestGenerator } from './src/generators/component-test/component-test';
export { setupTailwindGenerator } from './src/generators/setup-tailwind/setup-tailwind';
export type { SupportedStyles } from './typings/style';
export * from './plugins/with-react';
//# sourceMappingURL=index.d.ts.map

1
node_modules/@nx/react/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,IAAI,qBAAqB,EAAE,MAAM,2DAA2D,CAAC;AAE1H,kHAAkH;AAClH,eAAO,MAAM,oBAAoB,8BAAwB,CAAC;AAE1D,OAAO,EACL,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kDAAkD,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAC;AACzG,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,+BAA+B,EAAE,MAAM,kFAAkF,CAAC;AACnI,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,cAAc,sBAAsB,CAAC"}

46
node_modules/@nx/react/index.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupTailwindGenerator = exports.componentTestGenerator = exports.cypressComponentConfigGenerator = exports.remoteGenerator = exports.hostGenerator = exports.storybookConfigurationGenerator = exports.storiesGenerator = exports.reduxGenerator = exports.reactInitGenerator = exports.libraryGenerator = exports.componentStoryGenerator = exports.hookGenerator = exports.componentGenerator = exports.applicationGenerator = exports.reactVersion = exports.reactDomVersion = exports.assertValidStyle = exports.cssInJsDependenciesBabel = exports.extendReactEslintJson = exports.extraEslintDependencies = exports.NxReactWebpackPlugin = void 0;
const tslib_1 = require("tslib");
const nx_react_webpack_plugin_1 = require("./plugins/nx-react-webpack-plugin/nx-react-webpack-plugin");
/** @deprecated Use '@nx/react/webpack-plugin' instead, which can improve graph creation by 150-200ms per file. */
exports.NxReactWebpackPlugin = nx_react_webpack_plugin_1.NxReactWebpackPlugin;
var lint_1 = require("./src/utils/lint");
Object.defineProperty(exports, "extraEslintDependencies", { enumerable: true, get: function () { return lint_1.extraEslintDependencies; } });
Object.defineProperty(exports, "extendReactEslintJson", { enumerable: true, get: function () { return lint_1.extendReactEslintJson; } });
var styled_1 = require("./src/utils/styled");
Object.defineProperty(exports, "cssInJsDependenciesBabel", { enumerable: true, get: function () { return styled_1.cssInJsDependenciesBabel; } });
var assertion_1 = require("./src/utils/assertion");
Object.defineProperty(exports, "assertValidStyle", { enumerable: true, get: function () { return assertion_1.assertValidStyle; } });
var versions_1 = require("./src/utils/versions");
Object.defineProperty(exports, "reactDomVersion", { enumerable: true, get: function () { return versions_1.reactDomVersion; } });
Object.defineProperty(exports, "reactVersion", { enumerable: true, get: function () { return versions_1.reactVersion; } });
var application_1 = require("./src/generators/application/application");
Object.defineProperty(exports, "applicationGenerator", { enumerable: true, get: function () { return application_1.applicationGenerator; } });
var component_1 = require("./src/generators/component/component");
Object.defineProperty(exports, "componentGenerator", { enumerable: true, get: function () { return component_1.componentGenerator; } });
var hook_1 = require("./src/generators/hook/hook");
Object.defineProperty(exports, "hookGenerator", { enumerable: true, get: function () { return hook_1.hookGenerator; } });
var component_story_1 = require("./src/generators/component-story/component-story");
Object.defineProperty(exports, "componentStoryGenerator", { enumerable: true, get: function () { return component_story_1.componentStoryGenerator; } });
var library_1 = require("./src/generators/library/library");
Object.defineProperty(exports, "libraryGenerator", { enumerable: true, get: function () { return library_1.libraryGenerator; } });
var init_1 = require("./src/generators/init/init");
Object.defineProperty(exports, "reactInitGenerator", { enumerable: true, get: function () { return init_1.reactInitGenerator; } });
var redux_1 = require("./src/generators/redux/redux");
Object.defineProperty(exports, "reduxGenerator", { enumerable: true, get: function () { return redux_1.reduxGenerator; } });
var stories_1 = require("./src/generators/stories/stories");
Object.defineProperty(exports, "storiesGenerator", { enumerable: true, get: function () { return stories_1.storiesGenerator; } });
var configuration_1 = require("./src/generators/storybook-configuration/configuration");
Object.defineProperty(exports, "storybookConfigurationGenerator", { enumerable: true, get: function () { return configuration_1.storybookConfigurationGenerator; } });
var host_1 = require("./src/generators/host/host");
Object.defineProperty(exports, "hostGenerator", { enumerable: true, get: function () { return host_1.hostGenerator; } });
var remote_1 = require("./src/generators/remote/remote");
Object.defineProperty(exports, "remoteGenerator", { enumerable: true, get: function () { return remote_1.remoteGenerator; } });
var cypress_component_configuration_1 = require("./src/generators/cypress-component-configuration/cypress-component-configuration");
Object.defineProperty(exports, "cypressComponentConfigGenerator", { enumerable: true, get: function () { return cypress_component_configuration_1.cypressComponentConfigGenerator; } });
var component_test_1 = require("./src/generators/component-test/component-test");
Object.defineProperty(exports, "componentTestGenerator", { enumerable: true, get: function () { return component_test_1.componentTestGenerator; } });
var setup_tailwind_1 = require("./src/generators/setup-tailwind/setup-tailwind");
Object.defineProperty(exports, "setupTailwindGenerator", { enumerable: true, get: function () { return setup_tailwind_1.setupTailwindGenerator; } });
tslib_1.__exportStar(require("./plugins/with-react"), exports);

70
node_modules/@nx/react/mf/dynamic-federation.d.ts generated vendored Normal file
View File

@@ -0,0 +1,70 @@
export type ResolveRemoteUrlFunction = (remoteName: string) => string | Promise<string>;
/**
* @deprecated Use Runtime Helpers from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
*/
export declare function setRemoteUrlResolver(_resolveRemoteUrl: ResolveRemoteUrlFunction): void;
/**
* @deprecated Use init() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
* If you have a remote app called `my-remote-app` and you want to use the `http://localhost:4201/mf-manifest.json` as the remote url, you should change it from:
* ```ts
* import { setRemoteDefinitions } from '@nx/react/mf';
*
* setRemoteDefinitions({
* 'my-remote-app': 'http://localhost:4201/mf-manifest.json'
* });
* ```
* to use init():
* ```ts
* import { init } from '@module-federation/enhanced/runtime';
*
* init({
* name: 'host',
* remotes: [{
* name: 'my-remote-app',
* entry: 'http://localhost:4201/mf-manifest.json'
* }]
* });
* ```
*/
export declare function setRemoteDefinitions(definitions: Record<string, string>): void;
/**
* @deprecated Use registerRemotes() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
* If you set a remote app with `setRemoteDefinition` such as:
* ```ts
* import { setRemoteDefinition } from '@nx/react/mf';
*
* setRemoteDefinition(
* 'my-remote-app',
* 'http://localhost:4201/mf-manifest.json'
* );
* ```
* change it to use registerRemotes():
* ```ts
* import { registerRemotes } from '@module-federation/enhanced/runtime';
*
* registerRemotes([
* {
* name: 'my-remote-app',
* entry: 'http://localhost:4201/mf-manifest.json'
* }
* ]);
* ```
*/
export declare function setRemoteDefinition(remoteName: string, remoteUrl: string): void;
/**
* @deprecated Use loadRemote() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
* If you set a load a remote with `loadRemoteModule` such as:
* ```ts
* import { loadRemoteModule } from '@nx/react/mf';
*
* loadRemoteModule('my-remote-app', './Module').then(m => m.RemoteEntryModule);
* ```
* change it to use loadRemote():
* ```ts
* import { loadRemote } from '@module-federation/enhanced/runtime';
*
* loadRemote<typeof import('my-remote-app/Module')>('my-remote-app/Module').then(m => m.RemoteEntryModule);
* ```
*/
export declare function loadRemoteModule(remoteName: string, moduleName: string): Promise<any>;
//# sourceMappingURL=dynamic-federation.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"dynamic-federation.d.ts","sourceRoot":"","sources":["../../../../packages/react/mf/dynamic-federation.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,wBAAwB,GAAG,CACrC,UAAU,EAAE,MAAM,KACf,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAqB9B;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,iBAAiB,EAAE,wBAAwB,QAG5C;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAEvE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAGxE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAgB5E"}

141
node_modules/@nx/react/mf/dynamic-federation.js generated vendored Normal file
View File

@@ -0,0 +1,141 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setRemoteUrlResolver = setRemoteUrlResolver;
exports.setRemoteDefinitions = setRemoteDefinitions;
exports.setRemoteDefinition = setRemoteDefinition;
exports.loadRemoteModule = loadRemoteModule;
const url_helpers_1 = require("@nx/module-federation/url-helpers");
let remoteUrlDefinitions;
let resolveRemoteUrl;
const remoteModuleMap = new Map();
const remoteContainerMap = new Map();
let initialSharingScopeCreated = false;
/**
* @deprecated Use Runtime Helpers from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
*/
function setRemoteUrlResolver(_resolveRemoteUrl) {
resolveRemoteUrl = _resolveRemoteUrl;
}
/**
* @deprecated Use init() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
* If you have a remote app called `my-remote-app` and you want to use the `http://localhost:4201/mf-manifest.json` as the remote url, you should change it from:
* ```ts
* import { setRemoteDefinitions } from '@nx/react/mf';
*
* setRemoteDefinitions({
* 'my-remote-app': 'http://localhost:4201/mf-manifest.json'
* });
* ```
* to use init():
* ```ts
* import { init } from '@module-federation/enhanced/runtime';
*
* init({
* name: 'host',
* remotes: [{
* name: 'my-remote-app',
* entry: 'http://localhost:4201/mf-manifest.json'
* }]
* });
* ```
*/
function setRemoteDefinitions(definitions) {
remoteUrlDefinitions = definitions;
}
/**
* @deprecated Use registerRemotes() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
* If you set a remote app with `setRemoteDefinition` such as:
* ```ts
* import { setRemoteDefinition } from '@nx/react/mf';
*
* setRemoteDefinition(
* 'my-remote-app',
* 'http://localhost:4201/mf-manifest.json'
* );
* ```
* change it to use registerRemotes():
* ```ts
* import { registerRemotes } from '@module-federation/enhanced/runtime';
*
* registerRemotes([
* {
* name: 'my-remote-app',
* entry: 'http://localhost:4201/mf-manifest.json'
* }
* ]);
* ```
*/
function setRemoteDefinition(remoteName, remoteUrl) {
remoteUrlDefinitions ??= {};
remoteUrlDefinitions[remoteName] = remoteUrl;
}
/**
* @deprecated Use loadRemote() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
* If you set a load a remote with `loadRemoteModule` such as:
* ```ts
* import { loadRemoteModule } from '@nx/react/mf';
*
* loadRemoteModule('my-remote-app', './Module').then(m => m.RemoteEntryModule);
* ```
* change it to use loadRemote():
* ```ts
* import { loadRemote } from '@module-federation/enhanced/runtime';
*
* loadRemote<typeof import('my-remote-app/Module')>('my-remote-app/Module').then(m => m.RemoteEntryModule);
* ```
*/
async function loadRemoteModule(remoteName, moduleName) {
const remoteModuleKey = `${remoteName}:${moduleName}`;
if (remoteModuleMap.has(remoteModuleKey)) {
return remoteModuleMap.get(remoteModuleKey);
}
const container = remoteContainerMap.has(remoteName)
? remoteContainerMap.get(remoteName)
: await loadRemoteContainer(remoteName);
const factory = await container.get(moduleName);
const Module = factory();
remoteModuleMap.set(remoteModuleKey, Module);
return Module;
}
const fetchRemoteModule = (url, remoteName) => {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = url;
script.type = 'text/javascript';
script.async = true;
script.onload = () => {
const proxy = {
get: (request) => window[remoteName].get(request),
init: (arg) => {
try {
window[remoteName].init(arg);
}
catch (e) {
console.error(`Failed to initialize remote ${remoteName}`, e);
reject(e);
}
},
};
resolve(proxy);
};
script.onerror = () => reject(new Error(`Remote ${remoteName} not found`));
document.head.appendChild(script);
});
};
async function loadRemoteContainer(remoteName) {
if (!resolveRemoteUrl && !remoteUrlDefinitions) {
throw new Error('Call setRemoteDefinitions or setRemoteUrlResolver to allow Dynamic Federation to find the remote apps correctly.');
}
if (!initialSharingScopeCreated) {
initialSharingScopeCreated = true;
await __webpack_init_sharing__('default');
}
const remoteUrl = remoteUrlDefinitions
? remoteUrlDefinitions[remoteName]
: await resolveRemoteUrl(remoteName);
const containerUrl = (0, url_helpers_1.processRuntimeRemoteUrl)(remoteUrl, 'mjs');
const container = await fetchRemoteModule(containerUrl, remoteName);
await container.init(__webpack_share_scopes__.default);
remoteContainerMap.set(remoteName, container);
return container;
}

2
node_modules/@nx/react/mf/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export { loadRemoteModule, setRemoteDefinition, setRemoteDefinitions, setRemoteUrlResolver, } from './dynamic-federation';
//# sourceMappingURL=index.d.ts.map

1
node_modules/@nx/react/mf/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/react/mf/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC"}

8
node_modules/@nx/react/mf/index.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setRemoteUrlResolver = exports.setRemoteDefinitions = exports.setRemoteDefinition = exports.loadRemoteModule = void 0;
var dynamic_federation_1 = require("./dynamic-federation");
Object.defineProperty(exports, "loadRemoteModule", { enumerable: true, get: function () { return dynamic_federation_1.loadRemoteModule; } });
Object.defineProperty(exports, "setRemoteDefinition", { enumerable: true, get: function () { return dynamic_federation_1.setRemoteDefinition; } });
Object.defineProperty(exports, "setRemoteDefinitions", { enumerable: true, get: function () { return dynamic_federation_1.setRemoteDefinitions; } });
Object.defineProperty(exports, "setRemoteUrlResolver", { enumerable: true, get: function () { return dynamic_federation_1.setRemoteUrlResolver; } });

241
node_modules/@nx/react/migrations.json generated vendored Normal file
View File

@@ -0,0 +1,241 @@
{
"generators": {
"update-20-2-0-update-module-federation-config-import": {
"cli": "nx",
"version": "20.2.0-beta.2",
"description": "Update the ModuleFederationConfig import use @nx/module-federation.",
"factory": "./src/migrations/update-20-2-0/migrate-mf-imports-to-new-package"
},
"update-20-2-0-update-with-module-federation-import": {
"cli": "nx",
"version": "20.2.0-beta.2",
"description": "Update the withModuleFederation import use @nx/module-federation/webpack.",
"factory": "./src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package"
},
"ensure-nx-module-federation-package": {
"cli": "nx",
"version": "20.3.0-beta.2",
"description": "If workspace includes Module Federation projects, ensure the new @nx/module-federation package is installed.",
"factory": "./src/migrations/update-20-3-0/ensure-nx-module-federation-package"
},
"add-mf-env-var-to-target-defaults": {
"cli": "nx",
"version": "20.4.0-beta.0",
"description": "Add NX_MF_DEV_REMOTES to inputs for task hashing when '@nx/webpack:webpack' or '@nx/rspack:rspack' is used for Module Federation.",
"factory": "./src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults"
},
"update-21-0-0-update-babel-loose": {
"cli": "nx",
"version": "21.0.0-beta.11",
"description": "Replaces `classProperties.loose` option with `loose`.",
"factory": "./src/migrations/update-21-0-0/update-babel-loose"
},
"update-22-0-0-add-svgr-to-webpack-config": {
"cli": "nx",
"version": "22.0.0-beta.0",
"description": "Updates webpack configs using React to use the new withSvgr composable function instead of the svgr option in withReact or NxReactWebpackPlugin.",
"factory": "./src/migrations/update-22-0-0/add-svgr-to-webpack-config"
}
},
"packageJsonUpdates": {
"20.0.0": {
"version": "20.0.0-beta.8",
"packages": {
"eslint-plugin-import": {
"version": "2.31.0",
"alwaysAddToPackageJson": false
}
}
},
"20.1.0": {
"version": "20.1.0-beta.0",
"packages": {
"eslint-plugin-react-hooks": {
"version": "5.0.0",
"alwaysAddToPackageJson": false
},
"eslint-plugin-jsx-a11y": {
"version": "6.10.1",
"alwaysAddToPackageJson": false
}
}
},
"20.2.0": {
"version": "20.2.0-beta.3",
"packages": {
"@module-federation/enhanced": {
"version": "0.7.6",
"alwaysAddToPackageJson": false
},
"@module-federation/runtime": {
"version": "0.7.6",
"alwaysAddToPackageJson": false
},
"@module-federation/sdk": {
"version": "0.7.6",
"alwaysAddToPackageJson": false
},
"@module-federation/node": {
"version": "2.6.11",
"alwaysAddToPackageJson": false
}
}
},
"20.3.0": {
"version": "20.3.0-beta.0",
"packages": {
"@testing-library/react": {
"version": "16.1.0",
"alwaysAddToPackageJson": false
}
}
},
"21.4.0": {
"version": "21.4.0-beta.8",
"packages": {
"http-proxy-middleware": {
"version": "^3.0.5",
"alwaysAddToPackageJson": false
}
}
},
"22.2.0": {
"version": "22.2.0-beta.0",
"packages": {
"@module-federation/enhanced": {
"version": "^0.21.2",
"alwaysAddToPackageJson": false
},
"@module-federation/runtime": {
"version": "^0.21.2",
"alwaysAddToPackageJson": false
},
"@module-federation/sdk": {
"version": "^0.21.2",
"alwaysAddToPackageJson": false
},
"@module-federation/node": {
"version": "^2.7.21",
"alwaysAddToPackageJson": false
}
}
},
"22.2.0-emotion": {
"version": "22.2.0-beta.3",
"packages": {
"@emotion/react": {
"version": "11.14.0",
"alwaysAddToPackageJson": false
},
"@emotion/styled": {
"version": "11.14.1",
"alwaysAddToPackageJson": false
},
"@emotion/babel-plugin": {
"version": "11.13.5",
"alwaysAddToPackageJson": false
}
}
},
"22.3.4": {
"version": "22.3.4-beta.0",
"packages": {
"react-router-dom": {
"version": "6.30.3",
"alwaysAddToPackageJson": false
},
"react-router": {
"version": "7.12.0",
"alwaysAddToPackageJson": false
},
"@react-router/dev": {
"version": "7.12.0",
"alwaysAddToPackageJson": false
},
"@react-router/node": {
"version": "7.12.0",
"alwaysAddToPackageJson": false
},
"@react-router/serve": {
"version": "7.12.0",
"alwaysAddToPackageJson": false
},
"@react-router/express": {
"version": "7.12.0",
"alwaysAddToPackageJson": false
},
"@react-router/fs-routes": {
"version": "7.12.0",
"alwaysAddToPackageJson": false
},
"@react-router/cloudflare": {
"version": "7.12.0",
"alwaysAddToPackageJson": false
},
"@react-router/architect": {
"version": "7.12.0",
"alwaysAddToPackageJson": false
},
"@react-router/remix-routes-option-adapter": {
"version": "7.12.0",
"alwaysAddToPackageJson": false
}
}
},
"22.6.0": {
"version": "22.6.0-beta.10",
"x-prompt": "Bump @module-federation packages to v2.x to resolve koa CVE-2026-27959 (via dts-plugin)",
"packages": {
"@module-federation/enhanced": {
"version": "^2.1.0",
"alwaysAddToPackageJson": false
},
"@module-federation/node": {
"version": "^2.7.21",
"alwaysAddToPackageJson": false
}
}
},
"22.7.0": {
"version": "22.7.0-beta.18",
"packages": {
"react-router": {
"version": "7.14.2",
"alwaysAddToPackageJson": false
},
"@react-router/dev": {
"version": "7.14.2",
"alwaysAddToPackageJson": false
},
"@react-router/node": {
"version": "7.14.2",
"alwaysAddToPackageJson": false
},
"@react-router/serve": {
"version": "7.14.2",
"alwaysAddToPackageJson": false
},
"@react-router/express": {
"version": "7.14.2",
"alwaysAddToPackageJson": false
},
"@react-router/fs-routes": {
"version": "7.14.2",
"alwaysAddToPackageJson": false
},
"@react-router/cloudflare": {
"version": "7.14.2",
"alwaysAddToPackageJson": false
},
"@react-router/architect": {
"version": "7.14.2",
"alwaysAddToPackageJson": false
},
"@react-router/remix-routes-option-adapter": {
"version": "7.14.2",
"alwaysAddToPackageJson": false
}
}
}
}
}

7
node_modules/@nx/react/module-federation.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
import { withModuleFederation } from '@nx/module-federation/webpack';
import { withModuleFederationForSSR } from '@nx/module-federation/webpack';
/**
* @deprecated Use `@nx/module-federation/webpack` instead. This will be removed in Nx v22.
*/
export { withModuleFederation, withModuleFederationForSSR };
//# sourceMappingURL=module-federation.d.ts.map

1
node_modules/@nx/react/module-federation.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"module-federation.d.ts","sourceRoot":"","sources":["../../../packages/react/module-federation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E;;GAEG;AACH,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,CAAC"}

21
node_modules/@nx/react/module-federation.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withModuleFederationForSSR = exports.withModuleFederation = void 0;
const webpack_1 = require("@nx/module-federation/webpack");
Object.defineProperty(exports, "withModuleFederation", { enumerable: true, get: function () { return webpack_1.withModuleFederation; } });
const webpack_2 = require("@nx/module-federation/webpack");
Object.defineProperty(exports, "withModuleFederationForSSR", { enumerable: true, get: function () { return webpack_2.withModuleFederationForSSR; } });
// Support for older generated code: `const withModuleFederation = require('@nx/react/module-federation')`
/**
* @deprecated Use `@nx/module-federation/webpack` instead. This will be removed in Nx v22.
*/
module.exports = webpack_1.withModuleFederation;
// Allow newer generated code to work: `const { withModuleFederation } = require(...)`;
/**
* @deprecated Use `@nx/module-federation/webpack` instead. This will be removed in Nx v22.
*/
module.exports.withModuleFederation = webpack_1.withModuleFederation;
/**
* @deprecated Use `@nx/module-federation/webpack` instead. This will be removed in Nx v22.
*/
module.exports.withModuleFederationForSSR = webpack_2.withModuleFederationForSSR;

221
node_modules/@nx/react/package.json generated vendored Normal file
View File

@@ -0,0 +1,221 @@
{
"name": "@nx/react",
"version": "22.7.5",
"private": false,
"description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Vitest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/react"
},
"keywords": [
"Monorepo",
"React",
"Web",
"Jest",
"Cypress",
"CLI",
"Front-end"
],
"main": "./index.js",
"type": "commonjs",
"types": "./index.d.ts",
"author": "Victor Savkin",
"license": "MIT",
"bugs": {
"url": "https://github.com/nrwl/nx/issues"
},
"homepage": "https://nx.dev",
"executors": "./executors.json",
"generators": "./generators.json",
"ng-update": {
"requirements": {},
"migrations": "./migrations.json"
},
"dependencies": {
"@phenomnomnominal/tsquery": "~6.2.0",
"@svgr/webpack": "^8.0.1",
"minimatch": "10.2.5",
"picocolors": "^1.1.0",
"tslib": "^2.3.0",
"@nx/devkit": "22.7.5",
"@nx/js": "22.7.5",
"@nx/eslint": "22.7.5",
"@nx/web": "22.7.5",
"@nx/module-federation": "22.7.5",
"@nx/rollup": "22.7.5",
"express": "^4.21.2",
"http-proxy-middleware": "^3.0.5",
"semver": "^7.6.3"
},
"devDependencies": {
"@nx/cypress": "22.7.5",
"@nx/playwright": "22.7.5",
"@nx/rsbuild": "22.7.5",
"@nx/vite": "22.7.5",
"@nx/vitest": "22.7.5",
"@nx/webpack": "22.7.5",
"@nx/storybook": "22.7.5",
"nx": "22.7.5"
},
"optionalDependencies": {
"@nx/vite": "22.7.5"
},
"publishConfig": {
"access": "public"
},
"exports": {
".": {
"import": "./index.js",
"require": "./index.js",
"types": "./index.d.ts"
},
"./package.json": "./package.json",
"./migrations.json": "./migrations.json",
"./generators.json": "./generators.json",
"./executors.json": "./executors.json",
"./mf": {
"import": "./mf/index.js",
"require": "./mf/index.js",
"types": "./mf/index.d.ts"
},
"./babel": {
"import": "./babel.js",
"require": "./babel.js",
"types": "./babel.d.ts"
},
"./tailwind": {
"import": "./tailwind.js",
"require": "./tailwind.js",
"types": "./tailwind.d.ts"
},
"./module-federation": {
"import": "./module-federation.js",
"require": "./module-federation.js",
"types": "./module-federation.d.ts"
},
"./webpack-plugin": {
"import": "./webpack-plugin.js",
"require": "./webpack-plugin.js",
"types": "./webpack-plugin.d.ts"
},
"./router-plugin": {
"import": "./router-plugin.js",
"require": "./router-plugin.js",
"types": "./router-plugin.d.ts"
},
"./ast-utils": {
"import": "./ast-utils.js",
"require": "./ast-utils.js",
"types": "./ast-utils.d.ts"
},
"./plugins/storybook": {
"import": "./plugins/storybook/index.js",
"require": "./plugins/storybook/index.js",
"types": "./plugins/storybook/index.d.ts"
},
"./plugins/component-testing": {
"import": "./plugins/component-testing/index.js",
"require": "./plugins/component-testing/index.js",
"types": "./plugins/component-testing/index.d.ts"
},
"./plugins/webpack": {
"import": "./plugins/webpack.js",
"require": "./plugins/webpack.js",
"types": "./plugins/webpack.d.ts"
},
"./plugins/bundle-rollup": {
"import": "./plugins/bundle-rollup.js",
"require": "./plugins/bundle-rollup.js",
"types": "./plugins/bundle-rollup.d.ts"
},
"./plugins/jest": {
"import": "./plugins/jest.js",
"require": "./plugins/jest.js",
"types": "./plugins/jest.d.ts"
},
"./plugins/with-react": {
"import": "./plugins/with-react.js",
"require": "./plugins/with-react.js",
"types": "./plugins/with-react.d.ts"
},
"./src/utils": {
"import": "./src/utils/index.js",
"require": "./src/utils/index.js",
"types": "./src/utils/index.d.ts"
},
"./src/utils/*": {
"import": "./src/utils/*.js",
"require": "./src/utils/*.js",
"types": "./src/utils/*.d.ts"
},
"./src/generators/utils": {
"import": "./src/generators/utils/index.js",
"require": "./src/generators/utils/index.js",
"types": "./src/generators/utils/index.d.ts"
},
"./src/generators/*": {
"import": "./src/generators/*.js",
"require": "./src/generators/*.js",
"types": "./src/generators/*.d.ts"
},
"./src/generators/*/lib/*": {
"import": "./src/generators/*/lib/*.js",
"require": "./src/generators/*/lib/*.js",
"types": "./src/generators/*/lib/*.d.ts"
},
"./src/generators/*/*": {
"import": "./src/generators/*/*.js",
"require": "./src/generators/*/*.js",
"types": "./src/generators/*/*.d.ts"
},
"./src/generators/*/schema.json": "./src/generators/*/schema.json",
"./src/executors/*/schema.json": "./src/executors/*/schema.json",
"./src/executors/*.impl": {
"import": "./src/executors/*.impl.js",
"require": "./src/executors/*.impl.js",
"types": "./src/executors/*.impl.d.ts"
},
"./src/executors/*": {
"import": "./src/executors/*.js",
"require": "./src/executors/*.js",
"types": "./src/executors/*.d.ts"
},
"./src/executors/*/lib/*": {
"import": "./src/executors/*/lib/*.js",
"require": "./src/executors/*/lib/*.js",
"types": "./src/executors/*/lib/*.d.ts"
},
"./src/module-federation/*": {
"import": "./src/module-federation/*.js",
"require": "./src/module-federation/*.js",
"types": "./src/module-federation/*.d.ts"
},
"./src/plugins/*": {
"import": "./src/plugins/*.js",
"require": "./src/plugins/*.js",
"types": "./src/plugins/*.d.ts"
},
"./src/rules/*": {
"import": "./src/rules/*.js",
"require": "./src/rules/*.js",
"types": "./src/rules/*.d.ts"
},
"./src/*": {
"import": "./src/*.js",
"require": "./src/*.js",
"types": "./src/*.d.ts"
},
"./plugins/*": {
"import": "./plugins/*.js",
"require": "./plugins/*.js",
"types": "./plugins/*.d.ts"
},
"./mf/*": {
"import": "./mf/*.js",
"require": "./mf/*.js",
"types": "./mf/*.d.ts"
},
"./typings/*.d.ts": "./typings/*.d.ts"
}
}

2
node_modules/@nx/react/plugins/bundle-rollup.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=bundle-rollup.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bundle-rollup.d.ts","sourceRoot":"","sources":["../../../../packages/react/plugins/bundle-rollup.ts"],"names":[],"mappings":""}

50
node_modules/@nx/react/plugins/bundle-rollup.js generated vendored Normal file
View File

@@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @deprecated Use `withNx` function from `@nx/rollup/with-nx` in your rollup.config.cjs file instead. Use `nx g @nx/rollup:convert-to-inferred` to generate the rollup.config.cjs file if it does not exist.
*/
function getRollupOptions(options) {
const extraGlobals = {
react: 'React',
'react-dom': 'ReactDOM',
'styled-components': 'styled',
'@emotion/react': 'emotionReact',
'@emotion/styled': 'emotionStyled',
};
if (Array.isArray(options.output)) {
options.output.forEach((o) => {
o.globals = { ...o.globals, ...extraGlobals };
});
}
else {
options.output = {
...options.output,
globals: {
...options.output.globals,
...extraGlobals,
},
};
}
// React buildable libs support SVGR, but not for React Native.
// If imports fail, ignore it.
try {
const url = require('@rollup/plugin-url');
const svg = require('@svgr/rollup');
options.plugins = [
svg({
svgo: false,
titleProp: true,
ref: true,
}),
url({
limit: 10000, // 10kB
}),
...(Array.isArray(options.plugins) ? options.plugins : []),
];
}
catch {
// Ignored for React Native
}
return options;
}
module.exports = getRollupOptions;

View File

@@ -0,0 +1,38 @@
import { NxComponentTestingOptions } from '@nx/cypress/plugins/cypress-preset';
type ViteDevServer = {
framework: 'react';
bundler: 'vite';
viteConfig?: any;
};
type WebpackDevServer = {
framework: 'react';
bundler: 'webpack';
webpackConfig?: any;
};
/**
* React nx preset for Cypress Component Testing
*
* This preset contains the base configuration
* for your component tests that nx recommends.
* including a devServer that supports nx workspaces.
* you can easily extend this within your cypress config via spreading the preset
* @example
* export default defineConfig({
* component: {
* ...nxComponentTestingPreset(__dirname)
* // add your own config here
* }
* })
*
* @param pathToConfig will be used for loading project options and to construct the output paths for videos and screenshots
* @param options override options
*/
export declare function nxComponentTestingPreset(pathToConfig: string, options?: NxComponentTestingOptions): {
specPattern: string;
devServer: ViteDevServer | WebpackDevServer;
videosFolder: string;
screenshotsFolder: string;
chromeWebSecurity: boolean;
};
export {};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/react/plugins/component-testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,EAC1B,MAAM,oCAAoC,CAAC;AAsB5C,KAAK,aAAa,GAAG;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,GAAG,CAAC;CAClB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,SAAS,CAAC;IACnB,aAAa,CAAC,EAAE,GAAG,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,yBAAyB,GAClC;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,aAAa,GAAG,gBAAgB,CAAC;IAC5C,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAmIA"}

View File

@@ -0,0 +1,232 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.nxComponentTestingPreset = nxComponentTestingPreset;
const cypress_preset_1 = require("@nx/cypress/plugins/cypress-preset");
const ct_helpers_1 = require("@nx/cypress/src/utils/ct-helpers");
const devkit_1 = require("@nx/devkit");
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
const fs_1 = require("fs");
const path_1 = require("path");
/**
* React nx preset for Cypress Component Testing
*
* This preset contains the base configuration
* for your component tests that nx recommends.
* including a devServer that supports nx workspaces.
* you can easily extend this within your cypress config via spreading the preset
* @example
* export default defineConfig({
* component: {
* ...nxComponentTestingPreset(__dirname)
* // add your own config here
* }
* })
*
* @param pathToConfig will be used for loading project options and to construct the output paths for videos and screenshots
* @param options override options
*/
function nxComponentTestingPreset(pathToConfig, options) {
const basePresetSettings = (0, cypress_preset_1.nxBaseCypressPreset)(pathToConfig, {
testingType: 'component',
});
if (global.NX_GRAPH_CREATION) {
// this is only used by plugins, so we don't need the component testing
// options, cast to any to avoid type errors
return basePresetSettings;
}
const normalizedProjectRootPath = ['.ts', '.js'].some((ext) => pathToConfig.endsWith(ext))
? pathToConfig
: (0, path_1.dirname)(pathToConfig);
if (options?.bundler === 'vite') {
return {
...basePresetSettings,
specPattern: 'src/**/*.cy.{js,jsx,ts,tsx}',
devServer: {
...{ framework: 'react', bundler: 'vite' },
viteConfig: async () => {
const viteConfigPath = findViteConfig(normalizedProjectRootPath);
// TODO(jack): Remove this cast when @nx/react switches to
// moduleResolution: "nodenext". Vite 8 ships ESM-only type
// declarations (.d.mts) not resolvable under moduleResolution: "node".
const { mergeConfig, loadConfigFromFile, searchForWorkspaceRoot } = await Function('return import("vite")')();
const resolved = await loadConfigFromFile({
mode: 'watch',
command: 'serve',
}, viteConfigPath);
return mergeConfig(resolved.config, {
server: {
fs: {
allow: [
searchForWorkspaceRoot(normalizedProjectRootPath),
devkit_1.workspaceRoot,
(0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, 'node_modules/vite'),
],
},
},
});
},
},
};
}
let webpackConfig = null;
try {
const graph = (0, devkit_1.readCachedProjectGraph)();
const { targets: ctTargets, name: ctProjectName } = (0, ct_helpers_1.getProjectConfigByPath)(graph, pathToConfig);
const ctTargetName = options?.ctTargetName || 'component-test';
const ctConfigurationName = process.env.NX_CYPRESS_TARGET_CONFIGURATION;
const ctExecutorContext = (0, ct_helpers_1.createExecutorContext)(graph, ctTargets, ctProjectName, ctTargetName, ctConfigurationName);
let buildTarget = options?.buildTarget;
if (!buildTarget) {
const ctExecutorOptions = (0, devkit_1.readTargetOptions)({
project: ctProjectName,
target: ctTargetName,
configuration: ctConfigurationName,
}, ctExecutorContext);
buildTarget = ctExecutorOptions.devServerTarget;
}
if (!buildTarget) {
throw new Error(`Unable to find the 'devServerTarget' executor option in the '${ctTargetName}' target of the '${ctProjectName}' project`);
}
webpackConfig = buildTargetWebpack(ctExecutorContext, buildTarget, ctProjectName);
}
catch (e) {
if (e instanceof InvalidExecutorError) {
throw e;
}
devkit_1.logger.warn((0, devkit_1.stripIndents) `Unable to build a webpack config with the project graph.
Falling back to default webpack config.`);
devkit_1.logger.warn(e);
}
// Fallback config
if (!webpackConfig) {
const { buildBaseWebpackConfig } = require('./webpack-fallback');
webpackConfig = buildBaseWebpackConfig({
tsConfigPath: findTsConfig(normalizedProjectRootPath),
compiler: options?.compiler || 'babel',
});
}
return {
...basePresetSettings,
specPattern: 'src/**/*.cy.{js,jsx,ts,tsx}',
devServer: {
// cypress uses string union type,
// need to use const to prevent typing to string
// but don't want to use as const on webpackConfig
// so it is still user modifiable
...{ framework: 'react', bundler: 'webpack' },
webpackConfig,
},
};
}
/**
* apply the schema.json defaults from the @nx/web:webpack executor to the target options
*/
function withSchemaDefaults(target, context) {
const options = (0, devkit_1.readTargetOptions)(target, context);
options.compiler ??= 'babel';
options.deleteOutputPath ??= true;
options.vendorChunk ??= true;
options.commonChunk ??= true;
options.runtimeChunk ??= true;
options.sourceMap ??= true;
options.assets ??= [];
options.scripts ??= [];
options.styles ??= [];
options.budgets ??= [];
options.namedChunks ??= true;
options.outputHashing ??= 'none';
options.extractCss ??= true;
options.memoryLimit ??= 2048;
options.maxWorkers ??= 2;
options.fileReplacements ??= [];
options.buildLibsFromSource ??= true;
return options;
}
function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
const graph = ctx.projectGraph;
const parsed = (0, devkit_1.parseTargetString)(buildTarget, graph);
const buildableProjectConfig = graph.nodes[parsed.project]?.data;
const ctProjectConfig = graph.nodes[componentTestingProjectName]?.data;
if (!buildableProjectConfig || !ctProjectConfig) {
throw new Error((0, devkit_1.stripIndents) `Unable to load project configs from graph.
Using build target '${buildTarget}'
Has build config? ${!!buildableProjectConfig}
Has component config? ${!!ctProjectConfig}
`);
}
if (buildableProjectConfig.targets[parsed.target].executor !==
'@nx/webpack:webpack' &&
buildableProjectConfig.targets[parsed.target].executor !==
'@nx/rspack:rspack') {
throw new InvalidExecutorError(`The '${parsed.target}' target of the '${parsed.project}' project is not using the '@nx/webpack:webpack' or '@nx/rspack:rspack' executor. ` +
`Please make sure to use '@nx/webpack:webpack' or '@nx/rspack:rspack' executor in that target to use Cypress Component Testing.`);
}
const context = (0, ct_helpers_1.createExecutorContext)(graph, buildableProjectConfig.targets, parsed.project, parsed.target, parsed.target);
const { normalizeOptions, } = require('@nx/webpack/src/executors/webpack/lib/normalize-options');
const { resolveUserDefinedWebpackConfig, } = require('@nx/webpack/src/utils/webpack/resolve-user-defined-webpack-config');
const { composePluginsSync } = require('@nx/webpack/src/utils/config');
const { withNx } = require('@nx/webpack/src/utils/with-nx');
const { withWeb } = require('@nx/webpack/src/utils/with-web');
const options = normalizeOptions(withSchemaDefaults(parsed, context), devkit_1.workspaceRoot, buildableProjectConfig.root, (0, ts_solution_setup_1.getProjectSourceRoot)(buildableProjectConfig));
let customWebpack;
if (options.webpackConfig) {
customWebpack = resolveUserDefinedWebpackConfig(options.webpackConfig, options.tsConfig.startsWith(context.root)
? options.tsConfig
: (0, path_1.join)(context.root, options.tsConfig));
}
return async () => {
customWebpack = await customWebpack;
// For legacy `composePlugins(...)` setup, we need change some options to make Cypress CT work properly.
if (customWebpack &&
require('@nx/webpack').isNxWebpackComposablePlugin(customWebpack) // using inline since @nx/webpack may not be installed when using vite so top-level import would error
) {
return await customWebpack({}, {
options: {
...options,
// cypress will generate its own index.html from component-index.html
generateIndexHtml: false,
// causes issues with buildable libraries with ENOENT: no such file or directory, scandir error
extractLicenses: false,
root: devkit_1.workspaceRoot,
projectRoot: ctProjectConfig.root,
sourceRoot: (0, ts_solution_setup_1.getProjectSourceRoot)(ctProjectConfig),
},
context,
configuration: parsed.configuration,
});
}
else if (typeof customWebpack === 'object' ||
typeof customWebpack === 'function') {
// If this is a standard webpack config object or function, just return. it
return customWebpack;
}
return null; // return null to use fallback config
};
}
function findViteConfig(projectRootFullPath) {
const allowsExt = ['js', 'mjs', 'ts', 'cjs', 'mts', 'cts'];
for (const ext of allowsExt) {
if ((0, fs_1.existsSync)((0, path_1.join)(projectRootFullPath, `vite.config.${ext}`))) {
return (0, path_1.join)(projectRootFullPath, `vite.config.${ext}`);
}
}
}
function findTsConfig(projectRoot) {
const potentialConfigs = [
'cypress/tsconfig.json',
'cypress/tsconfig.cy.json',
'tsconfig.cy.json',
];
for (const config of potentialConfigs) {
if ((0, fs_1.existsSync)((0, path_1.join)(projectRoot, config))) {
return config;
}
}
}
class InvalidExecutorError extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'InvalidExecutorError';
}
}

View File

@@ -0,0 +1,6 @@
import { Configuration } from 'webpack';
export declare function buildBaseWebpackConfig({ tsConfigPath, compiler, }: {
tsConfigPath: string;
compiler: 'swc' | 'babel';
}): Configuration;
//# sourceMappingURL=webpack-fallback.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"webpack-fallback.d.ts","sourceRoot":"","sources":["../../../../../packages/react/plugins/component-testing/webpack-fallback.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxC,wBAAgB,sBAAsB,CAAC,EACrC,YAAiC,EACjC,QAAkB,GACnB,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,KAAK,GAAG,OAAO,CAAC;CAC3B,GAAG,aAAa,CAuEhB"}

View File

@@ -0,0 +1,126 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildBaseWebpackConfig = buildBaseWebpackConfig;
const tsconfig_paths_webpack_plugin_1 = require("tsconfig-paths-webpack-plugin");
const webpack_1 = require("@nx/webpack");
const ts_config_1 = require("@nx/js/src/utils/typescript/ts-config");
function buildBaseWebpackConfig({ tsConfigPath = 'tsconfig.cy.json', compiler = 'babel', }) {
const extensions = ['.ts', '.tsx', '.mjs', '.js', '.jsx'];
const config = {
target: 'web',
resolve: {
extensions,
plugins: [
new tsconfig_paths_webpack_plugin_1.TsconfigPathsPlugin({
configFile: tsConfigPath,
baseUrl: (0, ts_config_1.resolvePathsBaseUrl)(tsConfigPath),
extensions,
}),
],
},
mode: 'development',
devtool: false,
output: {
publicPath: '/',
chunkFilename: '[name].bundle.js',
},
module: {
rules: [
{
test: /\.(bmp|png|jpe?g|gif|webp|avif)$/,
type: 'asset',
parser: {
dataUrlCondition: {
maxSize: 10_000, // 10 kB
},
},
},
CSS_MODULES_LOADER,
],
},
};
if (compiler === 'swc') {
config.module.rules.push({
test: /\.([jt])sx?$/,
loader: require.resolve('swc-loader'),
exclude: /node_modules/,
options: {
jsc: {
parser: {
syntax: 'typescript',
decorators: true,
tsx: true,
},
transform: {
react: {
runtime: 'automatic',
},
},
loose: true,
},
},
});
}
if (compiler === 'babel') {
config.module.rules.push({
test: /\.(js|jsx|mjs|ts|tsx)$/,
loader: require.resolve('babel-loader'),
options: {
presets: [`@nx/react/babel`],
rootMode: 'upward',
babelrc: true,
},
});
}
return config;
}
const loaderModulesOptions = {
modules: {
mode: 'local',
getLocalIdent: webpack_1.getCSSModuleLocalIdent,
},
importLoaders: 1,
};
const commonLoaders = [
{
loader: require.resolve('style-loader'),
},
{
loader: require.resolve('css-loader'),
options: loaderModulesOptions,
},
];
const CSS_MODULES_LOADER = {
test: /\.css$|\.scss$|\.sass$|\.less$/,
oneOf: [
{
test: /\.module\.css$/,
use: commonLoaders,
},
{
test: /\.module\.(scss|sass)$/,
use: [
...commonLoaders,
{
loader: require.resolve('sass-loader'),
options: {
implementation: require('sass'),
sassOptions: {
fiber: false,
precision: 8,
},
},
},
],
},
{
test: /\.module\.less$/,
use: [
...commonLoaders,
{
loader: require.resolve('less-loader'),
},
],
},
],
};

2
node_modules/@nx/react/plugins/jest.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=jest.d.ts.map

1
node_modules/@nx/react/plugins/jest.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"jest.d.ts","sourceRoot":"","sources":["../../../../packages/react/plugins/jest.ts"],"names":[],"mappings":""}

55
node_modules/@nx/react/plugins/jest.js generated vendored Normal file
View File

@@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const path = tslib_1.__importStar(require("path"));
const devkit_1 = require("@nx/devkit");
const JS_SOURCE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'];
module.exports = {
process(src, filename, options) {
const assetFilename = JSON.stringify(path.basename(filename));
if (filename.match(/\.svg$/)) {
// Based on how SVGR generates a component name:
// https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
const pascalCaseFilename = (0, devkit_1.names)(path.parse(filename).name).className;
const componentName = `Svg${pascalCaseFilename}`;
return {
code: `const React = require('react');
module.exports = {
__esModule: true,
default: ${assetFilename},
ReactComponent: function ${componentName}(props) {
return React.createElement(
'svg',
Object.assign({}, props, { children: ${assetFilename} })
);
},
};`,
};
}
if (JS_SOURCE_EXTENSIONS.includes(path.extname(filename))) {
const transformer = getJsTransform(options.config?.transform ?? []);
if (transformer)
return transformer.process(src, filename, options);
}
// Fallback for unknown extensions
return {
code: `module.exports = ${assetFilename};`,
};
},
};
function getJsTransform(transformers) {
try {
if (transformers?.[1]?.includes('@swc/jest')) {
return require('@swc/jest').createTransformer();
}
}
catch {
// ignored
}
try {
return require('babel-jest').default.createTransformer();
}
catch {
// ignored
}
}

View File

@@ -0,0 +1,3 @@
import { Configuration, WebpackOptionsNormalized } from 'webpack';
export declare function applyReactConfig(options?: Record<string, any>, config?: Partial<WebpackOptionsNormalized | Configuration>): void;
//# sourceMappingURL=apply-react-config.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"apply-react-config.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/plugins/nx-react-webpack-plugin/lib/apply-react-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAElE,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EACjC,MAAM,GAAE,OAAO,CAAC,wBAAwB,GAAG,aAAa,CAAM,GAC7D,IAAI,CAUN"}

View File

@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyReactConfig = applyReactConfig;
function applyReactConfig(options = {}, config = {}) {
if (!process.env['NX_TASK_TARGET_PROJECT'])
return;
addHotReload(config);
// enable webpack node api
config.node = {
__dirname: true,
__filename: true,
};
}
function addHotReload(config) {
if (config.mode === 'development' &&
typeof config['devServer'] === 'object' &&
config['devServer']?.hot) {
// add `react-refresh/babel` to babel loader plugin
const babelLoader = config.module.rules.find((rule) => rule &&
typeof rule !== 'string' &&
rule.loader?.toString().includes('babel-loader'));
if (babelLoader && typeof babelLoader !== 'string') {
babelLoader.options['plugins'] = [
...(babelLoader.options['plugins'] || []),
[
require.resolve('react-refresh/babel'),
{
skipEnvCheck: true,
},
],
];
}
const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
config.plugins.push(new ReactRefreshPlugin({ overlay: false }));
}
}

View File

@@ -0,0 +1,7 @@
import { Compiler } from 'webpack';
export declare class NxReactWebpackPlugin {
private options;
constructor(options?: Record<string, any>);
apply(compiler: Compiler): void;
}
//# sourceMappingURL=nx-react-webpack-plugin.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"nx-react-webpack-plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/react/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGnC,qBAAa,oBAAoB;IACnB,OAAO,CAAC,OAAO;gBAAP,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAErD,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAGhC"}

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NxReactWebpackPlugin = void 0;
const apply_react_config_1 = require("./lib/apply-react-config");
class NxReactWebpackPlugin {
constructor(options = {}) {
this.options = options;
}
apply(compiler) {
(0, apply_react_config_1.applyReactConfig)(this.options, compiler.options);
}
}
exports.NxReactWebpackPlugin = NxReactWebpackPlugin;

4
node_modules/@nx/react/plugins/storybook/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import { Configuration } from 'webpack';
export declare const core: (prev: any, options: any) => any;
export declare const webpack: (storybookWebpackConfig: Configuration, options: any) => Promise<Configuration>;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/react/plugins/storybook/index.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,aAAa,EAId,MAAM,SAAS,CAAC;AAiDjB,eAAO,MAAM,IAAI,GAAI,SAAI,EAAE,YAAO,QAGhC,CAAC;AAqFH,eAAO,MAAM,OAAO,GAClB,wBAAwB,aAAkB,EAC1C,SAAS,GAAG,KACX,OAAO,CAAC,aAAa,CAuFvB,CAAC"}

176
node_modules/@nx/react/plugins/storybook/index.js generated vendored Normal file
View File

@@ -0,0 +1,176 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.webpack = exports.core = void 0;
const devkit_1 = require("@nx/devkit");
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
const config_1 = require("@nx/webpack/src/utils/config");
const fs_1 = require("fs");
const path_1 = require("path");
const webpack_1 = require("webpack");
const with_react_1 = require("../with-react");
const merge_plugins_1 = require("./merge-plugins");
// This is shamelessly taken from CRA and modified for NX use
// https://github.com/facebook/create-react-app/blob/4784997f0682e75eb32a897b4ffe34d735912e6c/packages/react-scripts/config/env.js#L71
function getClientEnvironment(mode) {
// Grab NODE_ENV and NX_* and STORYBOOK_* environment variables and prepare them to be
// injected into the application via DefinePlugin in webpack configuration.
const NX_PREFIX = /^NX_PUBLIC_/i;
const STORYBOOK_PREFIX = /^STORYBOOK_/i;
const raw = Object.keys(process.env)
.filter((key) => NX_PREFIX.test(key) || STORYBOOK_PREFIX.test(key))
.reduce((env, key) => {
env[key] = process.env[key];
return env;
}, {
// Useful for determining whether were running in production mode.
NODE_ENV: process.env.NODE_ENV || mode,
// Environment variables for Storybook
// https://github.com/storybookjs/storybook/blob/bdf9e5ed854b8d34e737eee1a4a05add88265e92/lib/core-common/src/utils/envs.ts#L12-L21
NODE_PATH: process.env.NODE_PATH || '',
STORYBOOK: process.env.STORYBOOK || 'true',
// This is to support CRA's public folder feature.
// In production we set this to dot(.) to allow the browser to access these assets
// even when deployed inside a subpath. (like in GitHub pages)
// In development this is just empty as we always serves from the root.
PUBLIC_URL: mode === 'production' ? '.' : '',
});
// Stringify all values so we can feed into webpack DefinePlugin
const stringified = Object.keys(raw).reduce((env, key) => {
env[`process.env.${key}`] = JSON.stringify(raw[key]);
return env;
},
// Provide a fallback for process.env itself to handle cases where code
// accesses process.env directly (e.g., in Cypress component testing)
{ 'process.env': '({})' });
return { stringified };
}
const core = (prev, options) => ({
...prev,
disableWebpackDefaults: true,
});
exports.core = core;
const getProjectData = async (storybookOptions) => {
const fallbackData = {
workspaceRoot: storybookOptions.configDir,
projectRoot: '',
sourceRoot: '',
};
// Edge-case: not running from Nx
if (!process.env.NX_WORKSPACE_ROOT)
return fallbackData;
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
const projectNode = projectGraph.nodes[process.env.NX_TASK_TARGET_PROJECT];
return projectNode
? {
workspaceRoot: process.env.NX_WORKSPACE_ROOT,
projectRoot: projectNode.data.root,
sourceRoot: (0, ts_solution_setup_1.getProjectSourceRoot)(projectNode.data),
projectNode,
}
: // Edge-case: missing project node
fallbackData;
};
const fixBabelConfigurationIfNeeded = (webpackConfig, projectData) => {
if (!projectData.projectNode)
return;
const isUsingBabelUpwardRootMode = Object.keys(projectData.projectNode.data.targets).find((k) => {
const targetConfig = projectData.projectNode.data.targets[k];
return (targetConfig.executor === '@nx/webpack:webpack' &&
targetConfig.options?.babelUpwardRootMode);
});
if (isUsingBabelUpwardRootMode)
return;
let babelrcPath;
for (const ext of ['', '.json', '.js', '.cjs', '.mjs', '.cts']) {
const candidate = (0, path_1.join)(projectData.workspaceRoot, projectData.projectRoot, `.babelrc${ext}`);
if ((0, fs_1.existsSync)(candidate)) {
babelrcPath = candidate;
break;
}
}
// Unexpected setup, skip.
if (!babelrcPath)
return;
let babelRuleItem;
for (const rule of webpackConfig.module.rules) {
if (typeof rule === 'string')
continue;
if (!rule || !Array.isArray(rule.use))
continue;
for (const item of rule.use) {
if (typeof item !== 'string' && item['loader'].includes('babel-loader')) {
babelRuleItem = item;
break;
}
}
}
if (babelRuleItem) {
babelRuleItem.options.configFile = babelrcPath;
}
};
const webpack = async (storybookWebpackConfig = {}, options) => {
devkit_1.logger.info('=> Loading Nx React Storybook Addon from "@nx/react/plugins/storybook"');
// In case anyone is missing dep and did not run migrations.
// See: https://github.com/nrwl/nx/issues/14455
try {
require.resolve('@nx/webpack');
}
catch {
throw new Error(`'@nx/webpack' package is not installed. Install it and try again.`);
}
const { withNx, withWeb } = require('@nx/webpack');
const projectData = await getProjectData(options);
const tsconfigPath = (0, fs_1.existsSync)((0, path_1.join)(projectData.projectRoot, 'tsconfig.storybook.json'))
? (0, path_1.join)(projectData.projectRoot, 'tsconfig.storybook.json')
: (0, path_1.join)(projectData.projectRoot, 'tsconfig.json');
// The 'tsconfig.json' is mainly for the cypress test to be able to run
// because it will look into the cypress project dir and it will not find tsconfig.storybook.json
fixBabelConfigurationIfNeeded(storybookWebpackConfig, projectData);
const builderOptions = {
...options,
root: projectData.workspaceRoot,
projectRoot: projectData.projectRoot,
sourceRoot: (0, ts_solution_setup_1.getProjectSourceRoot)(projectData.projectNode.data),
fileReplacements: [],
sourceMap: true,
styles: options.styles ?? [],
optimization: {},
tsConfig: tsconfigPath,
extractCss: storybookWebpackConfig.mode === 'production',
target: 'web',
};
// ESM build for modern browsers.
let baseWebpackConfig = {};
const configure = (0, config_1.composePluginsSync)(withNx({ target: 'web', skipTypeChecking: true }), (0, with_react_1.withReact)());
const finalConfig = configure(baseWebpackConfig, {
options: builderOptions,
// TODO(JamesHenry): replace as any type assertion with as ExecutorContext once the nx repo is updated to use https://github.com/nrwl/nx/pull/33095
context: { root: devkit_1.workspaceRoot }, // The context is not used here.
});
return {
...storybookWebpackConfig,
module: {
...storybookWebpackConfig.module,
rules: [
...storybookWebpackConfig.module.rules,
...finalConfig.module.rules,
],
},
resolve: {
...storybookWebpackConfig.resolve,
fallback: {
...storybookWebpackConfig.resolve?.fallback,
// Next.js and other React frameworks may have server-code that uses these modules.
// They are not meant for client-side components so skip the fallbacks.
assert: false,
path: false,
util: false,
},
plugins: (0, merge_plugins_1.mergePlugins)(...(storybookWebpackConfig.resolve.plugins ??
[]), ...(finalConfig.resolve
.plugins ?? [])),
},
plugins: (0, merge_plugins_1.mergePlugins)(new webpack_1.DefinePlugin(getClientEnvironment(storybookWebpackConfig.mode).stringified), ...(storybookWebpackConfig.plugins ?? []), ...(finalConfig.plugins ?? [])),
};
};
exports.webpack = webpack;

View File

@@ -0,0 +1,4 @@
import { ResolvePluginInstance, RuleSetRule, WebpackPluginInstance } from 'webpack';
export declare const mergeRules: (...args: RuleSetRule[]) => (WebpackPluginInstance | RuleSetRule)[];
export declare const mergePlugins: (...args: (WebpackPluginInstance | ResolvePluginInstance)[]) => (WebpackPluginInstance | ResolvePluginInstance)[];
//# sourceMappingURL=merge-plugins.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"merge-plugins.d.ts","sourceRoot":"","sources":["../../../../../packages/react/plugins/storybook/merge-plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,UAAU,GAAI,GAAG,MAAM,WAAW,EAAE,4CAWd,CAAC;AAEpC,eAAO,MAAM,YAAY,GACvB,GAAG,MAAM,CAAC,qBAAqB,GAAG,qBAAqB,CAAC,EAAE,KACzD,CAAC,qBAAqB,GAAG,qBAAqB,CAAC,EAc/C,CAAC"}

View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mergePlugins = exports.mergeRules = void 0;
const mergeRules = (...args) => args.reduce((rules, rule) => {
if (rules.some((includedPlugin) => includedPlugin.constructor.name === rule.constructor.name)) {
return rules;
}
return [...rules, rule];
}, []);
exports.mergeRules = mergeRules;
const mergePlugins = (...args) => args.reduce((plugins, plugin) => {
if (plugins.some((includedPlugin) => includedPlugin.constructor.name === plugin.constructor.name)) {
return plugins;
}
return [...plugins, plugin];
}, []);
exports.mergePlugins = mergePlugins;

2
node_modules/@nx/react/plugins/webpack.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=webpack.d.ts.map

1
node_modules/@nx/react/plugins/webpack.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../../../../packages/react/plugins/webpack.ts"],"names":[],"mappings":""}

6
node_modules/@nx/react/plugins/webpack.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const webpack_1 = require("@nx/webpack");
const with_react_1 = require("./with-react");
const plugin = (0, webpack_1.composePlugins)((0, webpack_1.withNx)(), (0, with_react_1.withReact)());
module.exports = plugin;

10
node_modules/@nx/react/plugins/with-react.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
import type { Configuration } from 'webpack';
import type { NxWebpackExecutionContext, WithWebOptions } from '@nx/webpack';
export interface WithReactOptions extends WithWebOptions {
}
/**
* @param {WithReactOptions} pluginOptions
* @returns {NxWebpackPlugin}
*/
export declare function withReact(pluginOptions?: WithReactOptions): (config: Configuration, context: NxWebpackExecutionContext) => Configuration;
//# sourceMappingURL=with-react.d.ts.map

1
node_modules/@nx/react/plugins/with-react.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"with-react.d.ts","sourceRoot":"","sources":["../../../../packages/react/plugins/with-react.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAK7E,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAE3D;;;GAGG;AACH,wBAAgB,SAAS,CAAC,aAAa,GAAE,gBAAqB,IAE1D,QAAQ,aAAa,EACrB,SAAS,yBAAyB,KACjC,aAAa,CAajB"}

21
node_modules/@nx/react/plugins/with-react.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withReact = withReact;
const apply_react_config_1 = require("./nx-react-webpack-plugin/lib/apply-react-config");
const processed = new Set();
/**
* @param {WithReactOptions} pluginOptions
* @returns {NxWebpackPlugin}
*/
function withReact(pluginOptions = {}) {
return function configure(config, context) {
const { withWeb } = require('@nx/webpack');
if (processed.has(config))
return config;
// Apply web config for CSS, JSX, index.html handling, etc.
config = withWeb(pluginOptions)(config, context);
(0, apply_react_config_1.applyReactConfig)({}, config);
processed.add(config);
return config;
};
}

2
node_modules/@nx/react/router-plugin.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export { createNodesV2, ReactRouterPluginOptions, } from './src/plugins/router-plugin';
//# sourceMappingURL=router-plugin.d.ts.map

1
node_modules/@nx/react/router-plugin.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"router-plugin.d.ts","sourceRoot":"","sources":["../../../packages/react/router-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,wBAAwB,GACzB,MAAM,6BAA6B,CAAC"}

5
node_modules/@nx/react/router-plugin.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createNodesV2 = void 0;
var router_plugin_1 = require("./src/plugins/router-plugin");
Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return router_plugin_1.createNodesV2; } });

View File

@@ -0,0 +1,3 @@
export * from './normalize-options';
export * from './start-remotes';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react/src/executors/module-federation-dev-server/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}

View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./normalize-options"), exports);
tslib_1.__exportStar(require("./start-remotes"), exports);

View File

@@ -0,0 +1,5 @@
import { ExecutorContext } from '@nx/devkit';
import { ModuleFederationDevServerOptions, NormalizedModuleFederationDevServerOptions } from '../schema';
export declare function getBuildOptions(buildTarget: string, context: ExecutorContext): any;
export declare function normalizeOptions(options: ModuleFederationDevServerOptions): NormalizedModuleFederationDevServerOptions;
//# sourceMappingURL=normalize-options.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"normalize-options.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react/src/executors/module-federation-dev-server/lib/normalize-options.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAGhB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gCAAgC,EAChC,0CAA0C,EAC3C,MAAM,WAAW,CAAC;AAEnB,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,OAQ5E;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,gCAAgC,GACxC,0CAA0C,CAM5C"}

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBuildOptions = getBuildOptions;
exports.normalizeOptions = normalizeOptions;
const devkit_1 = require("@nx/devkit");
function getBuildOptions(buildTarget, context) {
const target = (0, devkit_1.parseTargetString)(buildTarget, context);
const buildOptions = (0, devkit_1.readTargetOptions)(target, context);
return {
...buildOptions,
};
}
function normalizeOptions(options) {
return {
...options,
devRemotes: options.devRemotes ?? [],
verbose: options.verbose ?? false,
};
}

View File

@@ -0,0 +1,6 @@
import { ExecutorContext, ProjectConfiguration } from '@nx/devkit';
import { NormalizedModuleFederationDevServerOptions } from '../schema';
export declare function startRemotes(remotes: string[], workspaceProjects: Record<string, ProjectConfiguration>, options: Pick<NormalizedModuleFederationDevServerOptions, 'devRemotes' | 'host' | 'ssl' | 'sslCert' | 'sslKey' | 'verbose'>, context: ExecutorContext, target?: 'serve' | 'serve-static'): Promise<AsyncIterable<{
success: boolean;
}>[]>;
//# sourceMappingURL=start-remotes.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"start-remotes.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react/src/executors/module-federation-dev-server/lib/start-remotes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAe,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,0CAA0C,EAAE,MAAM,WAAW,CAAC;AAEvE,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EAAE,EACjB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EACvD,OAAO,EAAE,IAAI,CACX,0CAA0C,EAC1C,YAAY,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CACjE,EACD,OAAO,EAAE,eAAe,EACxB,MAAM,GAAE,OAAO,GAAG,cAAwB;aAEE,OAAO;MAgDpD"}

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.startRemotes = startRemotes;
const devkit_1 = require("@nx/devkit");
async function startRemotes(remotes, workspaceProjects, options, context, target = 'serve') {
const remoteIters = [];
for (const app of remotes) {
const remoteProjectServeTarget = workspaceProjects[app].targets[target];
const isUsingModuleFederationDevServerExecutor = remoteProjectServeTarget.executor.includes('module-federation-dev-server');
const configurationOverride = options.devRemotes?.find((r) => typeof r !== 'string' && r.remoteName === app)?.configuration;
const defaultOverrides = {
...(options.host ? { host: options.host } : {}),
...(options.ssl ? { ssl: options.ssl } : {}),
...(options.sslCert ? { sslCert: options.sslCert } : {}),
...(options.sslKey ? { sslKey: options.sslKey } : {}),
};
const overrides = target === 'serve'
? {
watch: true,
...(isUsingModuleFederationDevServerExecutor
? { isInitialHost: false }
: {}),
...defaultOverrides,
}
: { ...defaultOverrides };
remoteIters.push(await (0, devkit_1.runExecutor)({
project: app,
target,
configuration: configurationOverride ?? context.configurationName,
}, overrides, context));
}
return remoteIters;
}

View File

@@ -0,0 +1,7 @@
import { ExecutorContext } from '@nx/devkit';
import { ModuleFederationDevServerOptions } from './schema';
export default function moduleFederationDevServer(schema: ModuleFederationDevServerOptions, context: ExecutorContext): AsyncIterableIterator<{
success: boolean;
baseUrl?: string;
}>;
//# sourceMappingURL=module-federation-dev-server.impl.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"module-federation-dev-server.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/executors/module-federation-dev-server/module-federation-dev-server.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,YAAY,CAAC;AAarD,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAE5D,wBAA+B,yBAAyB,CACtD,MAAM,EAAE,gCAAgC,EACxC,OAAO,EAAE,eAAe,GACvB,qBAAqB,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAuG/D"}

View File

@@ -0,0 +1,76 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = moduleFederationDevServer;
const tslib_1 = require("tslib");
const devkit_1 = require("@nx/devkit");
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
const utils_1 = require("@nx/module-federation/src/executors/utils");
const file_server_impl_1 = tslib_1.__importDefault(require("@nx/web/src/executors/file-server/file-server.impl"));
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
const dev_server_impl_1 = tslib_1.__importDefault(require("@nx/webpack/src/executors/dev-server/dev-server.impl"));
const fs_1 = require("fs");
const path_1 = require("path");
const lib_1 = require("./lib");
async function* moduleFederationDevServer(schema, context) {
const options = (0, lib_1.normalizeOptions)(schema);
const currIter = options.static
? (0, file_server_impl_1.default)({
...options,
parallel: false,
withDeps: false,
spa: false,
cors: true,
cacheSeconds: -1,
}, context)
: // TODO(JamesHenry): remove type assertion once the nx repo is updated to use https://github.com/nrwl/nx/pull/33095
(0, dev_server_impl_1.default)(options, context);
const p = context.projectsConfigurations.projects[context.projectName];
let pathToManifestFile = (0, path_1.join)(context.root, (0, ts_solution_setup_1.getProjectSourceRoot)(p), 'assets/module-federation.manifest.json');
if (options.pathToManifestFile) {
const userPathToManifestFile = (0, path_1.join)(context.root, options.pathToManifestFile);
if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
throw new Error(`The provided Module Federation manifest file path does not exist. Please check the file exists at "${userPathToManifestFile}".`);
}
else if ((0, path_1.extname)(options.pathToManifestFile) !== '.json') {
throw new Error(`The Module Federation manifest file must be a JSON. Please ensure the file at ${userPathToManifestFile} is a JSON.`);
}
pathToManifestFile = userPathToManifestFile;
}
if (!options.isInitialHost) {
return yield* currIter;
}
const { staticRemotesIter, devRemoteIters, remotes } = await (0, utils_1.startRemoteIterators)(options, context, lib_1.startRemotes, pathToManifestFile, 'react');
return yield* (0, async_iterable_1.combineAsyncIterables)(currIter, ...devRemoteIters, ...(staticRemotesIter ? [staticRemotesIter] : []), (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
if (!options.isInitialHost) {
done();
return;
}
if (remotes.remotePorts.length === 0) {
done();
return;
}
try {
const host = options.host ?? 'localhost';
const baseUrl = `http${options.ssl ? 's' : ''}://${host}:${options.port}`;
const portsToWaitFor = staticRemotesIter && options.staticRemotesPort
? [options.staticRemotesPort, ...remotes.remotePorts]
: [...remotes.remotePorts];
await Promise.all(portsToWaitFor.map((port) => (0, wait_for_port_open_1.waitForPortOpen)(port, {
retries: 480,
retryDelay: 2500,
host: host,
})));
devkit_1.logger.info(`NX All remotes started, server ready at ${baseUrl}`);
next({ success: true, baseUrl: baseUrl });
}
catch (err) {
throw new Error(`Failed to start remotes. Check above for any errors.`, {
cause: err,
});
}
finally {
done();
}
}));
}

View File

@@ -0,0 +1,19 @@
import { WebDevServerOptions } from '@nx/webpack';
import { DevRemoteDefinition } from '@nx/module-federation/src/executors/utils';
export type ModuleFederationDevServerOptions = WebDevServerOptions & {
devRemotes?: DevRemoteDefinition[];
skipRemotes?: string[];
static?: boolean;
isInitialHost?: boolean;
parallel?: number;
staticRemotesPort?: number;
pathToManifestFile?: string;
verbose?: boolean;
};
export type NormalizedModuleFederationDevServerOptions =
ModuleFederationDevServerOptions & {
devRemotes: DevRemoteDefinition[];
verbose: boolean;
};

View File

@@ -0,0 +1,141 @@
{
"version": 2,
"continuous": true,
"outputCapture": "direct-nodejs",
"title": "Module Federation Dev Server",
"description": "Serve a web application.",
"cli": "nx",
"type": "object",
"properties": {
"devRemotes": {
"type": "array",
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "object",
"properties": {
"remoteName": {
"type": "string"
},
"configuration": {
"type": "string"
}
},
"required": ["remoteName"],
"additionalProperties": false
}
]
},
"description": "List of Producer (remote) applications to run in development mode (i.e. using serve target).",
"x-priority": "important",
"alias": "devProducers"
},
"skipRemotes": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of Producer (remote) applications to not automatically serve, either statically or in development mode. This will not remove the Producers (remotes) from the `module-federation.config` file, and therefore the application may still try to fetch these Producers (remotes).\nThis option is useful if you have other means for serving the Producer (remote) application(s).\n**NOTE:** Producers (remotes) that are not in the workspace will be skipped automatically.",
"x-priority": "important",
"alias": "skipProducers"
},
"buildTarget": {
"type": "string",
"description": "Target which builds the application.",
"x-priority": "important"
},
"port": {
"type": "number",
"description": "Port to listen on.",
"default": 4200,
"x-priority": "important"
},
"host": {
"type": "string",
"description": "Host to listen on.",
"default": "localhost"
},
"ssl": {
"type": "boolean",
"description": "Serve using `HTTPS`.",
"default": false
},
"sslKey": {
"type": "string",
"description": "SSL key to use for serving `HTTPS`."
},
"sslCert": {
"type": "string",
"description": "SSL certificate to use for serving `HTTPS`."
},
"watch": {
"type": "boolean",
"description": "Watches for changes and rebuilds application.",
"default": true
},
"liveReload": {
"type": "boolean",
"description": "Whether to reload the page on change, using live-reload.",
"default": true
},
"hmr": {
"type": "boolean",
"description": "Enable hot module replacement.",
"default": false
},
"publicHost": {
"type": "string",
"description": "Public URL where the application will be served."
},
"open": {
"type": "boolean",
"description": "Open the application in the browser.",
"default": false,
"x-priority": "important"
},
"allowedHosts": {
"type": "string",
"description": "This option allows you to whitelist services that are allowed to access the dev server."
},
"memoryLimit": {
"type": "number",
"description": "Memory limit for type checking service process in `MB`."
},
"maxWorkers": {
"type": "number",
"description": "Number of workers to use for type checking."
},
"baseHref": {
"type": "string",
"description": "Base url for the application being built."
},
"static": {
"type": "boolean",
"description": "Whether to use a static file server instead of the webpack-dev-server. This should be used for Producer (remote) applications that are also Consumer (host) applications."
},
"isInitialHost": {
"type": "boolean",
"description": "Whether the Consumer (host) that is running this executor is the first in the project tree to do so.",
"default": true,
"x-priority": "internal",
"alias": "isInitialConsumer"
},
"parallel": {
"type": "number",
"description": "Max number of parallel processes for building static Producers (remotes)"
},
"staticRemotesPort": {
"type": "number",
"description": "The port at which to serve the file-server for the static Producers (remotes).",
"alias": "staticProducersPort"
},
"pathToManifestFile": {
"type": "string",
"description": "Path to a Module Federation manifest file (e.g. `my/path/to/module-federation.manifest.json`) containing the dynamic Producer (remote) applications relative to the workspace root."
}
},
"examplesFile": "../../../docs/module-federation-dev-server-examples.md"
}

View File

@@ -0,0 +1,3 @@
export * from './normalize-options';
export * from './start-remotes';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react/src/executors/module-federation-ssr-dev-server/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}

View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./normalize-options"), exports);
tslib_1.__exportStar(require("./start-remotes"), exports);

View File

@@ -0,0 +1,5 @@
import { ModuleFederationSsrDevServerOptions, NormalizedModuleFederationSsrDevServerOptions } from '../schema';
import { ExecutorContext } from '@nx/devkit';
export declare function normalizeOptions(options: ModuleFederationSsrDevServerOptions): NormalizedModuleFederationSsrDevServerOptions;
export declare function getBuildOptions(buildTarget: string, context: ExecutorContext): any;
//# sourceMappingURL=normalize-options.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"normalize-options.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react/src/executors/module-federation-ssr-dev-server/lib/normalize-options.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mCAAmC,EACnC,6CAA6C,EAC9C,MAAM,WAAW,CAAC;AAEnB,OAAO,EAEL,eAAe,EAGhB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,mCAAmC,GAC3C,6CAA6C,CAS/C;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,OAQ5E"}

View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeOptions = normalizeOptions;
exports.getBuildOptions = getBuildOptions;
const path_1 = require("path");
const devkit_1 = require("@nx/devkit");
function normalizeOptions(options) {
return {
...options,
devRemotes: options.devRemotes ?? [],
verbose: options.verbose ?? false,
ssl: options.ssl ?? false,
sslCert: options.sslCert ? (0, path_1.join)(devkit_1.workspaceRoot, options.sslCert) : undefined,
sslKey: options.sslKey ? (0, path_1.join)(devkit_1.workspaceRoot, options.sslKey) : undefined,
};
}
function getBuildOptions(buildTarget, context) {
const target = (0, devkit_1.parseTargetString)(buildTarget, context);
const buildOptions = (0, devkit_1.readTargetOptions)(target, context);
return {
...buildOptions,
};
}

View File

@@ -0,0 +1,6 @@
import { ModuleFederationSsrDevServerOptions } from '../schema';
import { ExecutorContext, ProjectConfiguration } from '@nx/devkit';
export declare function startRemotes(remotes: string[], workspaceProjects: Record<string, ProjectConfiguration>, options: Partial<Pick<ModuleFederationSsrDevServerOptions, 'devRemotes' | 'host' | 'ssl' | 'sslCert' | 'sslKey' | 'verbose'>>, context: ExecutorContext): Promise<AsyncIterable<{
success: boolean;
}>[]>;
//# sourceMappingURL=start-remotes.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"start-remotes.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react/src/executors/module-federation-ssr-dev-server/lib/start-remotes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAe,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEhF,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EAAE,EACjB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EACvD,OAAO,EAAE,OAAO,CACd,IAAI,CACF,mCAAmC,EACnC,YAAY,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CACjE,CACF,EACD,OAAO,EAAE,eAAe;aAEoB,OAAO;MA2CpD"}

View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.startRemotes = startRemotes;
const devkit_1 = require("@nx/devkit");
async function startRemotes(remotes, workspaceProjects, options, context) {
const remoteIters = [];
const target = 'serve';
for (const app of remotes) {
const remoteProjectServeTarget = workspaceProjects[app].targets[target];
const isUsingModuleFederationSsrDevServerExecutor = remoteProjectServeTarget.executor.includes('module-federation-ssr-dev-server');
const configurationOverride = options.devRemotes?.find((remote) => typeof remote !== 'string' && remote.remoteName === app)?.configuration;
{
const defaultOverrides = {
...(options.host ? { host: options.host } : {}),
...(options.ssl ? { ssl: options.ssl } : {}),
...(options.sslCert ? { sslCert: options.sslCert } : {}),
...(options.sslKey ? { sslKey: options.sslKey } : {}),
};
const overrides = {
watch: true,
...defaultOverrides,
...(isUsingModuleFederationSsrDevServerExecutor
? { isInitialHost: false }
: {}),
};
remoteIters.push(await (0, devkit_1.runExecutor)({
project: app,
target,
configuration: configurationOverride ?? context.configurationName,
}, overrides, context));
}
}
return remoteIters;
}

View File

@@ -0,0 +1,4 @@
import { ExecutorContext } from '@nx/devkit';
import { ModuleFederationSsrDevServerOptions } from './schema';
export default function moduleFederationSsrDevServer(ssrDevServerOptions: ModuleFederationSsrDevServerOptions, context: ExecutorContext): AsyncGenerator<any, any, any>;
//# sourceMappingURL=module-federation-ssr-dev-server.impl.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"module-federation-ssr-dev-server.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,YAAY,CAAC;AAYrD,OAAO,EAAE,mCAAmC,EAAE,MAAM,UAAU,CAAC;AAE/D,wBAA+B,4BAA4B,CACzD,mBAAmB,EAAE,mCAAmC,EACxD,OAAO,EAAE,eAAe,iCA4GzB"}

View File

@@ -0,0 +1,78 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = moduleFederationSsrDevServer;
const tslib_1 = require("tslib");
const devkit_1 = require("@nx/devkit");
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
const utils_1 = require("@nx/module-federation/src/executors/utils");
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
const ssr_dev_server_impl_1 = tslib_1.__importDefault(require("@nx/webpack/src/executors/ssr-dev-server/ssr-dev-server.impl"));
const fs_1 = require("fs");
const path_1 = require("path");
const lib_1 = require("./lib");
async function* moduleFederationSsrDevServer(ssrDevServerOptions, context) {
const options = (0, lib_1.normalizeOptions)(ssrDevServerOptions);
// TODO(JamesHenry): remove type assertion once the nx repo is updated to use https://github.com/nrwl/nx/pull/33095
let iter = (0, ssr_dev_server_impl_1.default)(options, context);
const projectConfig = context.projectsConfigurations.projects[context.projectName];
let pathToManifestFile = (0, path_1.join)(context.root, (0, ts_solution_setup_1.getProjectSourceRoot)(projectConfig), 'assets/module-federation.manifest.json');
if (options.pathToManifestFile) {
const userPathToManifestFile = (0, path_1.join)(context.root, options.pathToManifestFile);
if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
throw new Error(`The provided Module Federation manifest file path does not exist. Please check the file exists at "${userPathToManifestFile}".`);
}
else if ((0, path_1.extname)(userPathToManifestFile) !== '.json') {
throw new Error(`The Module Federation manifest file must be a JSON. Please ensure the file at ${userPathToManifestFile} is a JSON.`);
}
pathToManifestFile = userPathToManifestFile;
}
if (!options.isInitialHost) {
return yield* iter;
}
const { staticRemotesIter, devRemoteIters, remotes } = await (0, utils_1.startRemoteIterators)(options, context, lib_1.startRemotes, pathToManifestFile, 'react', true);
const combined = (0, async_iterable_1.combineAsyncIterables)(staticRemotesIter, ...devRemoteIters);
let refs = 1 + (devRemoteIters?.length ?? 0);
for await (const result of combined) {
if (result.success === false)
throw new Error('Remotes failed to start');
if (result.success)
refs--;
if (refs === 0)
break;
}
return yield* (0, async_iterable_1.combineAsyncIterables)(iter, (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
const host = options.host ?? 'localhost';
const baseUrl = `http${options.ssl ? 's' : ''}://${host}:${options.port}`;
if (!options.isInitialHost) {
next({ success: true, baseUrl });
done();
return;
}
if (remotes.remotePorts.length === 0) {
next({ success: true, baseUrl });
done();
return;
}
try {
const portsToWaitFor = staticRemotesIter && options.staticRemotesPort
? [options.staticRemotesPort, ...remotes.remotePorts]
: [...remotes.remotePorts];
await Promise.all(portsToWaitFor.map((port) => (0, wait_for_port_open_1.waitForPortOpen)(port, {
retries: 480,
retryDelay: 2500,
host,
})));
devkit_1.logger.info(`Nx all ssr remotes have started, server ready at ${baseUrl}`);
next({ success: true, baseUrl });
}
catch (error) {
throw new Error(`Nx failed to start ssr remotes. Check above for errors.`, {
cause: error,
});
}
finally {
done();
}
}));
}

View File

@@ -0,0 +1,29 @@
import { WebSsrDevServerOptions } from '@nx/webpack/src/executors/ssr-dev-server/schema';
import { DevRemoteDefinition } from '@nx/module-federation/src/executors/utils';
export type ModuleFederationSsrDevServerOptions = WebSsrDevServerOptions & {
devRemotes?: (
| string
| {
remoteName: string;
configuration: string;
}
)[];
skipRemotes?: string[];
host: string;
pathToManifestFile?: string;
staticRemotesPort?: number;
parallel?: number;
ssl?: boolean;
sslKey?: string;
sslCert?: string;
isInitialHost?: boolean;
verbose?: boolean;
};
export type NormalizedModuleFederationSsrDevServerOptions =
ModuleFederationSsrDevServerOptions & {
devRemotes: DevRemoteDefinition[];
verbose: boolean;
};

View File

@@ -0,0 +1,80 @@
{
"version": 2,
"continuous": true,
"outputCapture": "direct-nodejs",
"title": "Module Federation SSR Dev Server",
"description": "Serve a SSR Consumer (host) application along with its known Producers (remotes).",
"cli": "nx",
"type": "object",
"properties": {
"browserTarget": {
"type": "string",
"description": "Target which builds the browser application.",
"x-priority": "important"
},
"serverTarget": {
"type": "string",
"description": "Target which builds the server application.",
"x-priority": "important"
},
"port": {
"type": "number",
"description": "The port to be set on `process.env.PORT` for use in the server.",
"default": 4200,
"x-priority": "important"
},
"devRemotes": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of Producer (remote) applications to run in development mode (i.e. using serve target).",
"x-priority": "important",
"alias": "devProducers"
},
"skipRemotes": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of Producer (remote) applications to not automatically serve, either statically or in development mode.",
"x-priority": "important",
"alias": "skipProducers"
},
"host": {
"type": "string",
"description": "Host to listen on.",
"default": "localhost"
},
"staticRemotesPort": {
"type": "number",
"description": "The port at which to serve the file-server for the static Producers (remotes).",
"alias": "staticProducersPort"
},
"pathToManifestFile": {
"type": "string",
"description": "Path to a Module Federation manifest file (e.g. `my/path/to/module-federation.manifest.json`) containing the dynamic Producer (remote) applications relative to the workspace root."
},
"ssl": {
"type": "boolean",
"description": "Serve using HTTPS.",
"default": false
},
"sslKey": {
"type": "string",
"description": "SSL key to use for serving HTTPS."
},
"sslCert": {
"type": "string",
"description": "SSL certificate to use for serving HTTPS."
},
"isInitialHost": {
"type": "boolean",
"description": "Whether the Consumer (host) that is running this executor is the first in the project tree to do so.",
"default": true,
"x-priority": "internal",
"alias": "isInitialConsumer"
}
},
"required": ["browserTarget", "serverTarget"]
}

View File

@@ -0,0 +1,13 @@
import { StaticRemotesConfig } from '@nx/module-federation/src/utils';
import { ExecutorContext } from 'nx/src/config/misc-interfaces';
import { ModuleFederationDevServerOptions } from '../module-federation-dev-server/schema';
import { ModuleFederationStaticServerSchema } from './schema';
export declare function startProxies(staticRemotesConfig: StaticRemotesConfig, hostServeOptions: ModuleFederationDevServerOptions, mappedLocationOfHost: string, mappedLocationsOfRemotes: Record<string, string>, sslOptions?: {
pathToCert: string;
pathToKey: string;
}): void;
export default function moduleFederationStaticServer(schema: ModuleFederationStaticServerSchema, context: ExecutorContext): AsyncGenerator<{
success: boolean;
baseUrl: string;
}, any, any>;
//# sourceMappingURL=module-federation-static-server.impl.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"module-federation-static-server.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/executors/module-federation-static-server/module-federation-static-server.impl.ts"],"names":[],"mappings":"AAaA,OAAO,EAIL,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAOzC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAC;AAC1F,OAAO,EAAE,kCAAkC,EAAE,MAAM,UAAU,CAAC;AAgJ9D,wBAAgB,YAAY,CAC1B,mBAAmB,EAAE,mBAAmB,EACxC,gBAAgB,EAAE,gCAAgC,EAClD,oBAAoB,EAAE,MAAM,EAC5B,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChD,UAAU,CAAC,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,QAgEvD;AAED,wBAA+B,4BAA4B,CACzD,MAAM,EAAE,kCAAkC,EAC1C,OAAO,EAAE,eAAe;;;aAiJzB"}

View File

@@ -0,0 +1,240 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.startProxies = startProxies;
exports.default = moduleFederationStaticServer;
const tslib_1 = require("tslib");
const devkit_1 = require("@nx/devkit");
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
const utils_1 = require("@nx/module-federation/src/executors/utils");
const utils_2 = require("@nx/module-federation/src/utils");
const file_server_impl_1 = tslib_1.__importDefault(require("@nx/web/src/executors/file-server/file-server.impl"));
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
const child_process_1 = require("child_process");
const fs_1 = require("fs");
const path_1 = require("path");
function getBuildAndServeOptionsFromServeTarget(serveTarget, context) {
const target = (0, devkit_1.parseTargetString)(serveTarget, context);
const serveOptions = (0, devkit_1.readTargetOptions)(target, context);
const buildTarget = (0, devkit_1.parseTargetString)(serveOptions.buildTarget, context);
const buildOptions = (0, devkit_1.readTargetOptions)(buildTarget, context);
let pathToManifestFile = (0, path_1.join)(context.root, (0, ts_solution_setup_1.getProjectSourceRoot)(context.projectGraph.nodes[context.projectName].data), 'assets/module-federation.manifest.json');
if (serveOptions.pathToManifestFile) {
const userPathToManifestFile = (0, path_1.join)(context.root, serveOptions.pathToManifestFile);
if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
throw new Error(`The provided Module Federation manifest file path does not exist. Please check the file exists at "${userPathToManifestFile}".`);
}
else if ((0, path_1.extname)(serveOptions.pathToManifestFile) !== '.json') {
throw new Error(`The Module Federation manifest file must be a JSON. Please ensure the file at ${userPathToManifestFile} is a JSON.`);
}
pathToManifestFile = userPathToManifestFile;
}
return {
buildTarget,
buildOptions,
serveOptions,
pathToManifestFile,
};
}
async function buildHost(nxBin, buildTarget, context) {
await new Promise((res, rej) => {
const staticProcess = (0, child_process_1.fork)(nxBin, [
`run`,
`${buildTarget.project}:${buildTarget.target}${buildTarget.configuration
? `:${buildTarget.configuration}`
: context.configurationName
? `:${context.configurationName}`
: ''}`,
], {
cwd: context.root,
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
});
staticProcess.stdout.on('data', (data) => {
const ANSII_CODE_REGEX = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
const stdoutString = data.toString().replace(ANSII_CODE_REGEX, '');
// in addition to writing into the stdout stream, also show error directly in console
// so the error is easily discoverable. 'ERROR in' is the key word to search in webpack output.
if (stdoutString.includes('ERROR in')) {
devkit_1.logger.log(stdoutString);
}
if (stdoutString.includes('Successfully ran target build')) {
staticProcess.stdout.removeAllListeners('data');
devkit_1.logger.info(`NX Built Consumer (host)`);
res();
}
});
staticProcess.stderr.on('data', (data) => devkit_1.logger.info(data.toString()));
staticProcess.once('exit', (code) => {
staticProcess.stdout.removeAllListeners('data');
staticProcess.stderr.removeAllListeners('data');
if (code !== 0) {
rej(`Consumer (host) failed to build. See above for details.`);
}
else {
res();
}
});
process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
process.on('exit', () => staticProcess.kill('SIGTERM'));
});
}
function moveToTmpDirectory(staticRemotesConfig, hostOutputPath, hostUrlSegment) {
const commonOutputDirectory = (0, path_1.join)(devkit_1.workspaceRoot, 'tmp/static-module-federation');
for (const app of staticRemotesConfig.remotes) {
const remoteConfig = staticRemotesConfig.config[app];
(0, fs_1.cpSync)(remoteConfig.outputPath, (0, path_1.join)(commonOutputDirectory, remoteConfig.urlSegment), {
force: true,
recursive: true,
});
}
(0, fs_1.cpSync)(hostOutputPath, (0, path_1.join)(commonOutputDirectory, hostUrlSegment), {
force: true,
recursive: true,
});
const cleanup = () => {
(0, fs_1.rmSync)(commonOutputDirectory, { force: true, recursive: true });
};
process.on('SIGTERM', () => {
cleanup();
});
process.on('exit', () => {
cleanup();
});
return commonOutputDirectory;
}
function startProxies(staticRemotesConfig, hostServeOptions, mappedLocationOfHost, mappedLocationsOfRemotes, sslOptions) {
const { createProxyMiddleware } = require('http-proxy-middleware');
const express = require('express');
let sslCert;
let sslKey;
if (sslOptions && sslOptions.pathToCert && sslOptions.pathToKey) {
if ((0, fs_1.existsSync)(sslOptions.pathToCert) && (0, fs_1.existsSync)(sslOptions.pathToKey)) {
sslCert = (0, fs_1.readFileSync)(sslOptions.pathToCert);
sslKey = (0, fs_1.readFileSync)(sslOptions.pathToKey);
}
else {
devkit_1.logger.warn(`Encountered SSL options in project.json, however, the certificate files do not exist in the filesystem. Using http.`);
devkit_1.logger.warn(`Attempted to find '${sslOptions.pathToCert}' and '${sslOptions.pathToKey}'.`);
}
}
const http = require('http');
const https = require('https');
devkit_1.logger.info(`NX Starting static remotes proxies...`);
for (const app of staticRemotesConfig.remotes) {
const expressProxy = express();
expressProxy.use(createProxyMiddleware({
target: mappedLocationsOfRemotes[app],
changeOrigin: true,
secure: sslCert ? false : undefined,
}));
const proxyServer = (sslCert ? https : http)
.createServer({ cert: sslCert, key: sslKey }, expressProxy)
.listen(staticRemotesConfig.config[app].port);
process.on('SIGTERM', () => proxyServer.close());
process.on('exit', () => proxyServer.close());
}
devkit_1.logger.info(`NX Static Producers (remotes) proxies started successfully`);
devkit_1.logger.info(`NX Starting static Consumer (host) proxy...`);
const expressProxy = express();
expressProxy.use(createProxyMiddleware({
target: mappedLocationOfHost,
changeOrigin: true,
secure: sslCert ? false : undefined,
pathRewrite: (path) => {
let pathRewrite = path;
for (const app of staticRemotesConfig.remotes) {
if (path.endsWith(app)) {
pathRewrite = '/';
break;
}
}
return pathRewrite;
},
}));
const proxyServer = (sslCert ? https : http)
.createServer({ cert: sslCert, key: sslKey }, expressProxy)
.listen(hostServeOptions.port);
process.on('SIGTERM', () => proxyServer.close());
process.on('exit', () => proxyServer.close());
devkit_1.logger.info('NX Static Consumer (host) proxy started successfully');
}
async function* moduleFederationStaticServer(schema, context) {
// Force Node to resolve to look for the nx binary that is inside node_modules
const nxBin = require.resolve('nx/bin/nx');
// Get the remotes from the module federation config
const p = context.projectsConfigurations.projects[context.projectName];
const options = getBuildAndServeOptionsFromServeTarget(schema.serveTarget, context);
const moduleFederationConfig = (0, utils_2.getModuleFederationConfig)(options.buildOptions.tsConfig, context.root, p.root, 'react');
const remotes = (0, utils_2.getRemotes)([], options.serveOptions.skipRemotes, moduleFederationConfig, {
projectName: context.projectName,
projectGraph: context.projectGraph,
root: context.root,
}, options.pathToManifestFile);
const staticRemotesConfig = (0, utils_2.parseStaticRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
options.serveOptions.staticRemotesPort ??= remotes.staticRemotePort;
const mappedLocationsOfStaticRemotes = await (0, utils_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options.serveOptions);
// Build the host
const hostUrlSegment = (0, path_1.basename)(options.buildOptions.outputPath);
const mappedLocationOfHost = `http${options.serveOptions.ssl ? 's' : ''}://${options.serveOptions.host}:${options.serveOptions.staticRemotesPort}/${hostUrlSegment}`;
await buildHost(nxBin, options.buildTarget, context);
// Move to a temporary directory
const commonOutputDirectory = moveToTmpDirectory(staticRemotesConfig, options.buildOptions.outputPath, hostUrlSegment);
// File Serve the temporary directory
const staticFileServerIter = (0, file_server_impl_1.default)({
cors: true,
watch: false,
staticFilePath: commonOutputDirectory,
parallel: false,
spa: false,
withDeps: false,
host: options.serveOptions.host,
port: options.serveOptions.staticRemotesPort,
ssl: options.serveOptions.ssl,
sslCert: options.serveOptions.sslCert,
sslKey: options.serveOptions.sslKey,
cacheSeconds: -1,
}, context);
// express proxy all of it
startProxies(staticRemotesConfig, options.serveOptions, mappedLocationOfHost, mappedLocationsOfStaticRemotes, options.serveOptions.ssl
? {
pathToCert: (0, path_1.join)(devkit_1.workspaceRoot, options.serveOptions.sslCert),
pathToKey: (0, path_1.join)(devkit_1.workspaceRoot, options.serveOptions.sslKey),
}
: undefined);
return yield* (0, async_iterable_1.combineAsyncIterables)(staticFileServerIter, (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
const host = options.serveOptions.host ?? 'localhost';
const baseUrl = `http${options.serveOptions.ssl ? 's' : ''}://${host}:${options.serveOptions.port}`;
if (remotes.remotePorts.length === 0) {
const portsToWaitFor = [options.serveOptions.staticRemotesPort];
await Promise.all(portsToWaitFor.map((port) => (0, wait_for_port_open_1.waitForPortOpen)(port, {
retries: 480,
retryDelay: 2500,
host: host,
})));
devkit_1.logger.info(`NX Server ready at ${baseUrl}`);
next({ success: true, baseUrl: baseUrl });
done();
return;
}
try {
const portsToWaitFor = staticFileServerIter && options.serveOptions.staticRemotesPort
? [options.serveOptions.staticRemotesPort, ...remotes.remotePorts]
: [...remotes.remotePorts];
await Promise.all(portsToWaitFor.map((port) => (0, wait_for_port_open_1.waitForPortOpen)(port, {
retries: 480,
retryDelay: 2500,
host: host,
})));
devkit_1.logger.info(`NX Server ready at ${baseUrl}`);
next({ success: true, baseUrl: baseUrl });
}
catch (err) {
throw new Error(`Failed to start. Check above for any errors.`, {
cause: err,
});
}
finally {
done();
}
}));
}

View File

@@ -0,0 +1,3 @@
export interface ModuleFederationStaticServerSchema {
serveTarget: string;
}

View File

@@ -0,0 +1,15 @@
{
"version": 2,
"continuous": true,
"outputCapture": "direct-nodejs",
"title": "Module Federation Static Dev Server",
"description": "Serve a Consumer (host) application statically along with its Producers (remotes).",
"cli": "nx",
"type": "object",
"properties": {
"serveTarget": {
"type": "string"
}
},
"required": ["serveTarget"]
}

View File

@@ -0,0 +1,6 @@
import { GeneratorCallback, Tree } from '@nx/devkit';
import { Schema } from './schema';
export declare function applicationGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
export declare function applicationGeneratorInternal(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
export default applicationGenerator;
//# sourceMappingURL=application.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/application/application.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAIjB,IAAI,EAGL,MAAM,YAAY,CAAC;AAoCpB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,CAAC,CAM5B;AAED,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,CAAC,CAqM5B;AAED,eAAe,oBAAoB,CAAC"}

View File

@@ -0,0 +1,185 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applicationGenerator = applicationGenerator;
exports.applicationGeneratorInternal = applicationGeneratorInternal;
const tslib_1 = require("tslib");
const devkit_1 = require("@nx/devkit");
const js_1 = require("@nx/js");
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
const create_ts_config_1 = require("../../utils/create-ts-config");
const add_styled_dependencies_1 = require("../../rules/add-styled-dependencies");
const setup_tailwind_1 = require("../setup-tailwind/setup-tailwind");
const init_1 = tslib_1.__importDefault(require("../init/init"));
const create_application_files_1 = require("./lib/create-application-files");
const update_jest_config_1 = require("./lib/update-jest-config");
const normalize_options_1 = require("./lib/normalize-options");
const add_project_1 = require("./lib/add-project");
const add_jest_1 = require("./lib/add-jest");
const add_routing_1 = require("./lib/add-routing");
const set_defaults_1 = require("./lib/set-defaults");
const add_linting_1 = require("./lib/add-linting");
const add_e2e_1 = require("./lib/add-e2e");
const show_possible_warnings_1 = require("./lib/show-possible-warnings");
const install_common_dependencies_1 = require("./lib/install-common-dependencies");
const add_webpack_1 = require("./lib/bundlers/add-webpack");
const add_rspack_1 = require("./lib/bundlers/add-rspack");
const add_rsbuild_1 = require("./lib/bundlers/add-rsbuild");
const add_vite_1 = require("./lib/bundlers/add-vite");
const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
const prompt_1 = require("@nx/devkit/src/generators/prompt");
async function applicationGenerator(tree, schema) {
return await applicationGeneratorInternal(tree, {
addPlugin: false,
useProjectJson: true,
...schema,
});
}
async function applicationGeneratorInternal(tree, schema) {
const tasks = [];
const addTsPlugin = (0, ts_solution_setup_1.shouldConfigureTsSolutionSetup)(tree, schema.addPlugin, schema.useTsSolution);
const jsInitTask = await (0, js_1.initGenerator)(tree, {
...schema,
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
skipFormat: true,
addTsPlugin,
formatter: schema.formatter,
platform: 'web',
});
tasks.push(jsInitTask);
const options = await (0, normalize_options_1.normalizeOptions)(tree, schema);
options.useReactRouter =
options.routing && options.bundler === 'vite'
? (options.useReactRouter ??
(await (0, prompt_1.promptWhenInteractive)({
name: 'response',
message: 'Would you like to use react-router for server-side rendering?',
type: 'autocomplete',
choices: [
{
name: 'Yes',
message: 'I want to use react-router [ https://reactrouter.com/start/framework/routing ]',
},
{
name: 'No',
message: 'I do not want to use react-router for server-side rendering',
},
],
initial: 0,
}, { response: 'No' }).then((r) => r.response === 'Yes')))
: false;
(0, show_possible_warnings_1.showPossibleWarnings)(tree, options);
const initTask = await (0, init_1.default)(tree, {
...options,
skipFormat: true,
useReactRouterPlugin: options.useReactRouter,
});
tasks.push(initTask);
if (!options.addPlugin) {
const nxJson = (0, devkit_1.readNxJson)(tree);
nxJson.targetDefaults ??= {};
if (!Object.keys(nxJson.targetDefaults).includes('build')) {
nxJson.targetDefaults.build = {
cache: true,
dependsOn: ['^build'],
};
}
else if (!nxJson.targetDefaults.build.dependsOn) {
nxJson.targetDefaults.build.dependsOn = ['^build'];
}
(0, devkit_1.updateNxJson)(tree, nxJson);
}
if (options.bundler === 'webpack') {
await (0, add_webpack_1.initWebpack)(tree, options, tasks);
}
else if (options.bundler === 'rspack') {
await (0, add_rspack_1.initRspack)(tree, options, tasks);
}
else if (options.bundler === 'rsbuild') {
await (0, add_rsbuild_1.initRsbuild)(tree, options, tasks);
}
if (!options.rootProject) {
(0, create_ts_config_1.extractTsConfigBase)(tree);
}
await (0, create_application_files_1.createApplicationFiles)(tree, options);
(0, add_project_1.addProject)(tree, options);
// If we are using the new TS solution
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
if (options.isUsingTsSolutionConfig) {
await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
}
if (options.style === 'tailwind') {
const twTask = await (0, setup_tailwind_1.setupTailwindGenerator)(tree, {
project: options.projectName,
});
tasks.push(twTask);
}
const lintTask = await (0, add_linting_1.addLinting)(tree, options);
tasks.push(lintTask);
if (options.bundler === 'vite') {
await (0, add_vite_1.setupViteConfiguration)(tree, options, tasks);
}
else if (options.bundler === 'rsbuild') {
await (0, add_rsbuild_1.setupRsbuildConfiguration)(tree, options, tasks);
}
if (options.bundler !== 'vite' && options.unitTestRunner === 'vitest') {
await (0, add_vite_1.setupVitestConfiguration)(tree, options, tasks);
}
if ((options.bundler === 'vite' || options.unitTestRunner === 'vitest') &&
options.inSourceTests) {
tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/app/${options.fileName}.spec.tsx`));
}
const e2eTask = await (0, add_e2e_1.addE2e)(tree, options);
tasks.push(e2eTask);
if (options.unitTestRunner === 'jest') {
const jestTask = await (0, add_jest_1.addJest)(tree, options);
tasks.push(jestTask);
}
// Handle tsconfig.spec.json for jest or vitest
(0, update_jest_config_1.updateSpecConfig)(tree, options);
const commonDependencyTask = await (0, install_common_dependencies_1.installCommonDependencies)(tree, options);
tasks.push(commonDependencyTask);
const styledTask = (0, add_styled_dependencies_1.addStyledModuleDependencies)(tree, options);
tasks.push(styledTask);
if (!options.useReactRouter) {
const routingTask = (0, add_routing_1.addRouting)(tree, options);
tasks.push(routingTask);
}
(0, set_defaults_1.setDefaults)(tree, options);
if (options.bundler === 'rspack' && options.style === 'styled-jsx') {
(0, add_rspack_1.handleStyledJsxForRspack)(tasks, tree, options);
}
if (options.useReactRouter) {
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json'), (json) => {
const types = new Set(json.compilerOptions?.types || []);
types.add('@react-router/node');
types.add('node');
return {
...json,
compilerOptions: {
...json.compilerOptions,
jsx: 'react-jsx',
moduleResolution: 'bundler',
types: Array.from(types),
},
};
});
}
// Only for the new TS solution
(0, ts_solution_setup_1.updateTsconfigFiles)(tree, options.appProjectRoot, 'tsconfig.app.json', {
jsx: 'react-jsx',
module: 'esnext',
moduleResolution: 'bundler',
}, options.linter === 'eslint'
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
: undefined, options.useReactRouter ? 'app' : 'src');
(0, sort_fields_1.sortPackageJsonFields)(tree, options.appProjectRoot);
if (!options.skipFormat) {
await (0, devkit_1.formatFiles)(tree);
}
tasks.push(() => {
(0, log_show_project_command_1.logShowProjectCommand)(options.projectName);
});
return (0, devkit_1.runTasksInSerial)(...tasks);
}
exports.default = applicationGenerator;

View File

@@ -0,0 +1,10 @@
import { render } from '@testing-library/react';
<%_ if (routing) { _%>
import { BrowserRouter } from 'react-router-dom';
<%_ } _%>
import App from './<%= fileName %>';
describe('App', () => {
<%- appTests _%>
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title><%= className %></title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
<div id="root"></div>
</body>
</html>

View File

@@ -0,0 +1,32 @@
<%_ if (strict) { _%>import { StrictMode } from 'react';<%_ } _%>
import * as ReactDOM from 'react-dom/client';
<%_ if (routing) { _%>import { BrowserRouter } from 'react-router-dom';<%_ } _%>
import App from './app/<%= fileName %>';
<%_ if(hasStyleFile) { _%>
import './styles.<%= style %>'
<%_ } _%>
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
<%_ if(strict && !routing) { _%>
root.render(
<StrictMode>
<App/>
</StrictMode>
)
<%_ } _%>
<%_ if(!strict && routing) { _%>
root.render(
<BrowserRouter>
<App/>
</BrowserRouter>
)
<%_ } _%>
<%_ if(strict && routing) { _%>
root.render(
<StrictMode>
<BrowserRouter>
<App/>
</BrowserRouter>
</StrictMode>
)
<%_ } _%>

View File

@@ -0,0 +1,31 @@
<%_ if (isUsingTsSolutionSetup) { _%>{
"extends": "<%= offsetFromRoot%>tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
"jsx": "react-jsx",
"lib": ["dom"],
"types": [
"node",
<%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts"
]
},
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
}<% } else { %>{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
"types": [
"node",
<%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts"
]
},
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
}
<% } %>

View File

@@ -0,0 +1,53 @@
<%_ if (rspackPluginOptions) { _%>
const { NxAppRspackPlugin } = require('@nx/rspack/app-plugin');
const { NxReactRspackPlugin } = require('@nx/rspack/react-plugin');
const { join } = require('path');
module.exports = {
output: {
path: join(__dirname, '<%= rspackPluginOptions.outputPath %>'),
},
devServer: {
port: <%= port %>,
historyApiFallback: {
index: '/index.html',
disableDotRule: true,
htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
},
},
plugins: [
new NxAppRspackPlugin({
tsConfig: '<%= rspackPluginOptions.tsConfig %>',
main: '<%= rspackPluginOptions.main %>',
index: '<%= rspackPluginOptions.index %>',
baseHref: '<%= rspackPluginOptions.baseHref %>',
assets: <%- JSON.stringify(rspackPluginOptions.assets) %>,
styles: <%- JSON.stringify(rspackPluginOptions.styles) %>,
outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
optimization: process.env['NODE_ENV'] === 'production',
}),
new NxReactRspackPlugin({
// Uncomment this line if you don't want to use SVGR
// See: https://react-svgr.com/
// svgr: false
}),
],
};
<%_ } else { _%>
const { composePlugins, withNx, withReact } = require('@nx/rspack');
// Nx plugins for rspack.
module.exports = composePlugins(
withNx(),
withReact({
// Uncomment this line if you don't want to use SVGR
// See: https://react-svgr.com/
// svgr: false
}),
(config) => {
// Update the rspack config as needed here.
// e.g. `config.plugins.push(new MyPlugin())`
return config;
}
);
<%_ } _%>

Some files were not shown because too many files have changed in this diff Show More