@nx/next 0.0.0-pr-22179-271588f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +68 -0
- package/babel.d.ts +0 -0
- package/babel.js +12 -0
- package/executors.json +20 -0
- package/generators.json +47 -0
- package/index.d.ts +8 -0
- package/index.js +19 -0
- package/migrations.json +106 -0
- package/package.json +60 -0
- package/plugin.d.ts +1 -0
- package/plugin.js +5 -0
- package/plugins/component-testing.d.ts +2 -0
- package/plugins/component-testing.js +96 -0
- package/plugins/with-less.d.ts +3 -0
- package/plugins/with-less.js +79 -0
- package/plugins/with-nx.d.ts +25 -0
- package/plugins/with-nx.js +297 -0
- package/plugins/with-stylus.d.ts +3 -0
- package/plugins/with-stylus.js +12 -0
- package/src/executors/build/build.impl.d.ts +5 -0
- package/src/executors/build/build.impl.js +106 -0
- package/src/executors/build/lib/check-project.d.ts +1 -0
- package/src/executors/build/lib/check-project.js +12 -0
- package/src/executors/build/lib/create-next-config-file.d.ts +14 -0
- package/src/executors/build/lib/create-next-config-file.js +162 -0
- package/src/executors/build/lib/test-fixtures/ensure-exts/baz.json +1 -0
- package/src/executors/build/lib/update-package-json.d.ts +3 -0
- package/src/executors/build/lib/update-package-json.js +30 -0
- package/src/executors/build/schema.json +76 -0
- package/src/executors/export/export.impl.d.ts +17 -0
- package/src/executors/export/export.impl.js +58 -0
- package/src/executors/export/schema.json +30 -0
- package/src/executors/server/custom-server.impl.d.ts +6 -0
- package/src/executors/server/custom-server.impl.js +36 -0
- package/src/executors/server/schema.json +63 -0
- package/src/executors/server/server.impl.d.ts +6 -0
- package/src/executors/server/server.impl.js +66 -0
- package/src/generators/application/application.d.ts +4 -0
- package/src/generators/application/application.js +85 -0
- package/src/generators/application/files/app/api/hello/route.ts__tmpl__ +4 -0
- package/src/generators/application/files/app/global.__stylesExt____tmpl__ +1 -0
- package/src/generators/application/files/app/page.module.__style__ +1 -0
- package/src/generators/application/files/app/page.tsx__tmpl__ +30 -0
- package/src/generators/application/files/app-default-layout/layout.tsx__tmpl__ +18 -0
- package/src/generators/application/files/app-styled-components/layout.tsx__tmpl__ +21 -0
- package/src/generators/application/files/app-styled-components/registry.tsx__tmpl__ +33 -0
- package/src/generators/application/files/app-styled-jsx/layout.tsx__tmpl__ +16 -0
- package/src/generators/application/files/app-styled-jsx/registry.tsx__tmpl__ +23 -0
- package/src/generators/application/files/common/__dot__babelrc +21 -0
- package/src/generators/application/files/common/index.d.ts__tmpl__ +13 -0
- package/src/generators/application/files/common/next-env.d.ts__tmpl__ +5 -0
- package/src/generators/application/files/common/next.config.js__tmpl__ +82 -0
- package/src/generators/application/files/common/public/.gitkeep +0 -0
- package/src/generators/application/files/common/public/favicon.ico +0 -0
- package/src/generators/application/files/common/specs/__fileName__.spec.tsx__tmpl__ +18 -0
- package/src/generators/application/files/common/tsconfig.json__tmpl__ +29 -0
- package/src/generators/application/files/pages/__fileName__.module.__style__ +1 -0
- package/src/generators/application/files/pages/__fileName__.tsx__tmpl__ +30 -0
- package/src/generators/application/files/pages/_app.tsx__tmpl__ +18 -0
- package/src/generators/application/files/pages/_document.tsx__tmpl__ +33 -0
- package/src/generators/application/files/pages/styles.__stylesExt____tmpl__ +1 -0
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +72 -0
- package/src/generators/application/lib/add-jest.d.ts +3 -0
- package/src/generators/application/lib/add-jest.js +38 -0
- package/src/generators/application/lib/add-linting.d.ts +3 -0
- package/src/generators/application/lib/add-linting.js +62 -0
- package/src/generators/application/lib/add-plugin.d.ts +2 -0
- package/src/generators/application/lib/add-plugin.js +25 -0
- package/src/generators/application/lib/add-project.d.ts +3 -0
- package/src/generators/application/lib/add-project.js +66 -0
- package/src/generators/application/lib/create-application-files.d.ts +3 -0
- package/src/generators/application/lib/create-application-files.helpers.d.ts +2 -0
- package/src/generators/application/lib/create-application-files.helpers.js +846 -0
- package/src/generators/application/lib/create-application-files.js +114 -0
- package/src/generators/application/lib/normalize-options.d.ts +14 -0
- package/src/generators/application/lib/normalize-options.js +56 -0
- package/src/generators/application/lib/set-defaults.d.ts +3 -0
- package/src/generators/application/lib/set-defaults.js +14 -0
- package/src/generators/application/lib/show-possible-warnings.d.ts +3 -0
- package/src/generators/application/lib/show-possible-warnings.js +10 -0
- package/src/generators/application/lib/update-cypress-tsconfig.d.ts +3 -0
- package/src/generators/application/lib/update-cypress-tsconfig.js +16 -0
- package/src/generators/application/lib/update-jest-config.d.ts +3 -0
- package/src/generators/application/lib/update-jest-config.js +15 -0
- package/src/generators/application/schema.d.ts +24 -0
- package/src/generators/application/schema.json +146 -0
- package/src/generators/component/component.d.ts +28 -0
- package/src/generators/component/component.js +66 -0
- package/src/generators/component/schema.json +125 -0
- package/src/generators/custom-server/custom-server.d.ts +3 -0
- package/src/generators/custom-server/custom-server.js +104 -0
- package/src/generators/custom-server/files/server/main.ts__tmpl__ +46 -0
- package/src/generators/custom-server/files/tsconfig.server.json__tmpl__ +17 -0
- package/src/generators/custom-server/schema.d.ts +4 -0
- package/src/generators/custom-server/schema.json +30 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +5 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +87 -0
- package/src/generators/cypress-component-configuration/schema.d.ts +6 -0
- package/src/generators/cypress-component-configuration/schema.json +42 -0
- package/src/generators/init/init.d.ts +5 -0
- package/src/generators/init/init.js +46 -0
- package/src/generators/init/lib/add-plugin.d.ts +2 -0
- package/src/generators/init/lib/add-plugin.js +26 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +34 -0
- package/src/generators/library/lib/normalize-options.d.ts +7 -0
- package/src/generators/library/lib/normalize-options.js +26 -0
- package/src/generators/library/library.d.ts +5 -0
- package/src/generators/library/library.js +92 -0
- package/src/generators/library/schema.d.ts +28 -0
- package/src/generators/library/schema.json +156 -0
- package/src/generators/page/page.d.ts +5 -0
- package/src/generators/page/page.js +96 -0
- package/src/generators/page/schema.d.ts +20 -0
- package/src/generators/page/schema.json +111 -0
- package/src/migrations/update-15-8-8/add-style-packages.d.ts +3 -0
- package/src/migrations/update-15-8-8/add-style-packages.js +23 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-3-0/remove-root-build-option.d.ts +2 -0
- package/src/migrations/update-16-3-0/remove-root-build-option.js +17 -0
- package/src/migrations/update-16-4-0/update-nx-next-dependency.d.ts +2 -0
- package/src/migrations/update-16-4-0/update-nx-next-dependency.js +17 -0
- package/src/migrations/update-17-2-7/remove-eslint-rules-patch.d.ts +2 -0
- package/src/migrations/update-17-2-7/remove-eslint-rules-patch.js +15 -0
- package/src/plugins/plugin.d.ts +11 -0
- package/src/plugins/plugin.js +182 -0
- package/src/utils/add-gitignore-entry.d.ts +2 -0
- package/src/utils/add-gitignore-entry.js +17 -0
- package/src/utils/add-swc-to-custom-server.d.ts +2 -0
- package/src/utils/add-swc-to-custom-server.js +37 -0
- package/src/utils/compose-plugins.d.ts +3 -0
- package/src/utils/compose-plugins.js +22 -0
- package/src/utils/config-invalid-function.fixture.d.ts +0 -0
- package/src/utils/config-invalid-function.fixture.js +1 -0
- package/src/utils/config-not-a-function.fixture.d.ts +0 -0
- package/src/utils/config-not-a-function.fixture.js +1 -0
- package/src/utils/config.d.ts +13 -0
- package/src/utils/config.js +24 -0
- package/src/utils/constants.d.ts +1 -0
- package/src/utils/constants.js +4 -0
- package/src/utils/create-cli-options.d.ts +1 -0
- package/src/utils/create-cli-options.js +13 -0
- package/src/utils/create-copy-plugin.d.ts +2 -0
- package/src/utils/create-copy-plugin.js +64 -0
- package/src/utils/generate-globs.d.ts +5 -0
- package/src/utils/generate-globs.js +29 -0
- package/src/utils/styles.d.ts +67 -0
- package/src/utils/styles.js +67 -0
- package/src/utils/types.d.ts +57 -0
- package/src/utils/types.js +2 -0
- package/src/utils/versions.d.ts +12 -0
- package/src/utils/versions.js +15 -0
- package/tailwind.d.ts +2 -0
- package/tailwind.js +6 -0
- package/typings/image.d.ts +12 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadEsmModule = exports.createNodes = exports.createDependencies = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
9
|
+
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
10
|
+
const js_1 = require("@nx/js");
|
|
11
|
+
const cachePath = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'next.hash');
|
|
12
|
+
const targetsCache = (0, fs_1.existsSync)(cachePath) ? readTargetsCache() : {};
|
|
13
|
+
const calculatedTargets = {};
|
|
14
|
+
function readTargetsCache() {
|
|
15
|
+
return (0, devkit_1.readJsonFile)(cachePath);
|
|
16
|
+
}
|
|
17
|
+
function writeTargetsToCache(targets) {
|
|
18
|
+
(0, devkit_1.writeJsonFile)(cachePath, targets);
|
|
19
|
+
}
|
|
20
|
+
const createDependencies = () => {
|
|
21
|
+
writeTargetsToCache(calculatedTargets);
|
|
22
|
+
return [];
|
|
23
|
+
};
|
|
24
|
+
exports.createDependencies = createDependencies;
|
|
25
|
+
exports.createNodes = [
|
|
26
|
+
'**/next.config.{js,cjs,mjs}',
|
|
27
|
+
async (configFilePath, options, context) => {
|
|
28
|
+
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
29
|
+
// Do not create a project if package.json and project.json isn't there.
|
|
30
|
+
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
31
|
+
if (!siblingFiles.includes('package.json') &&
|
|
32
|
+
!siblingFiles.includes('project.json')) {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
options = normalizeOptions(options);
|
|
36
|
+
const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [
|
|
37
|
+
(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
|
|
38
|
+
]);
|
|
39
|
+
const targets = targetsCache[hash] ??
|
|
40
|
+
(await buildNextTargets(configFilePath, projectRoot, options, context));
|
|
41
|
+
calculatedTargets[hash] = targets;
|
|
42
|
+
return {
|
|
43
|
+
projects: {
|
|
44
|
+
[projectRoot]: {
|
|
45
|
+
root: projectRoot,
|
|
46
|
+
targets,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
async function buildNextTargets(nextConfigPath, projectRoot, options, context) {
|
|
53
|
+
const nextConfig = await getNextConfig(nextConfigPath, context);
|
|
54
|
+
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
55
|
+
const targets = {};
|
|
56
|
+
targets[options.buildTargetName] = await getBuildTargetConfig(namedInputs, projectRoot, nextConfig);
|
|
57
|
+
targets[options.devTargetName] = getDevTargetConfig(projectRoot);
|
|
58
|
+
targets[options.startTargetName] = getStartTargetConfig(options, projectRoot);
|
|
59
|
+
targets[options.serveStaticTargetName] = getStaticServeTargetConfig(options);
|
|
60
|
+
return targets;
|
|
61
|
+
}
|
|
62
|
+
async function getBuildTargetConfig(namedInputs, projectRoot, nextConfig) {
|
|
63
|
+
const nextOutputPath = await getOutputs(projectRoot, nextConfig);
|
|
64
|
+
// Set output path here so that `withNx` can pick it up.
|
|
65
|
+
const targetConfig = {
|
|
66
|
+
command: `next build`,
|
|
67
|
+
options: {
|
|
68
|
+
cwd: projectRoot,
|
|
69
|
+
},
|
|
70
|
+
dependsOn: ['^build'],
|
|
71
|
+
cache: true,
|
|
72
|
+
inputs: getInputs(namedInputs),
|
|
73
|
+
outputs: [nextOutputPath, `${nextOutputPath}/!(cache)`],
|
|
74
|
+
};
|
|
75
|
+
return targetConfig;
|
|
76
|
+
}
|
|
77
|
+
function getDevTargetConfig(projectRoot) {
|
|
78
|
+
const targetConfig = {
|
|
79
|
+
command: `next dev`,
|
|
80
|
+
options: {
|
|
81
|
+
cwd: projectRoot,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
return targetConfig;
|
|
85
|
+
}
|
|
86
|
+
function getStartTargetConfig(options, projectRoot) {
|
|
87
|
+
const targetConfig = {
|
|
88
|
+
command: `next start`,
|
|
89
|
+
options: {
|
|
90
|
+
cwd: projectRoot,
|
|
91
|
+
},
|
|
92
|
+
dependsOn: [options.buildTargetName],
|
|
93
|
+
};
|
|
94
|
+
return targetConfig;
|
|
95
|
+
}
|
|
96
|
+
function getStaticServeTargetConfig(options) {
|
|
97
|
+
const targetConfig = {
|
|
98
|
+
executor: '@nx/web:file-server',
|
|
99
|
+
options: {
|
|
100
|
+
buildTarget: options.buildTargetName,
|
|
101
|
+
staticFilePath: '{projectRoot}/out',
|
|
102
|
+
port: 3000,
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
return targetConfig;
|
|
106
|
+
}
|
|
107
|
+
async function getOutputs(projectRoot, nextConfig) {
|
|
108
|
+
let dir = '.next';
|
|
109
|
+
const { PHASE_PRODUCTION_BUILD } = require('next/constants');
|
|
110
|
+
if (typeof nextConfig === 'function') {
|
|
111
|
+
// Works for both async and sync functions.
|
|
112
|
+
const configResult = await Promise.resolve(nextConfig(PHASE_PRODUCTION_BUILD, { defaultConfig: {} }));
|
|
113
|
+
if (configResult?.distDir) {
|
|
114
|
+
dir = configResult?.distDir;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else if (typeof nextConfig === 'object' && nextConfig?.distDir) {
|
|
118
|
+
// If nextConfig is an object, directly use its 'distDir' property.
|
|
119
|
+
dir = nextConfig.distDir;
|
|
120
|
+
}
|
|
121
|
+
if (projectRoot === '.') {
|
|
122
|
+
return `{projectRoot}/${dir}`;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
return `{workspaceRoot}/${projectRoot}/${dir}`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async function getNextConfig(configFilePath, context) {
|
|
129
|
+
const resolvedPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
|
|
130
|
+
let module;
|
|
131
|
+
if ((0, path_1.extname)(configFilePath) === '.mjs') {
|
|
132
|
+
module = await loadEsmModule(resolvedPath);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
module = load(resolvedPath);
|
|
136
|
+
}
|
|
137
|
+
return module.default ?? module;
|
|
138
|
+
}
|
|
139
|
+
function normalizeOptions(options) {
|
|
140
|
+
options ??= {};
|
|
141
|
+
options.buildTargetName ??= 'build';
|
|
142
|
+
options.devTargetName ??= 'dev';
|
|
143
|
+
options.startTargetName ??= 'start';
|
|
144
|
+
options.serveStaticTargetName ??= 'serve-static';
|
|
145
|
+
return options;
|
|
146
|
+
}
|
|
147
|
+
function getInputs(namedInputs) {
|
|
148
|
+
return [
|
|
149
|
+
...('production' in namedInputs
|
|
150
|
+
? ['default', '^production']
|
|
151
|
+
: ['default', '^default']),
|
|
152
|
+
{
|
|
153
|
+
externalDependencies: ['next'],
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
}
|
|
157
|
+
const packageInstallationDirectories = ['node_modules', '.yarn'];
|
|
158
|
+
/**
|
|
159
|
+
* Load the module after ensuring that the require cache is cleared.
|
|
160
|
+
*/
|
|
161
|
+
function load(path) {
|
|
162
|
+
// Clear cache if the path is in the cache
|
|
163
|
+
if (require.cache[path]) {
|
|
164
|
+
for (const key of Object.keys(require.cache)) {
|
|
165
|
+
if (!packageInstallationDirectories.some((dir) => key.includes(dir))) {
|
|
166
|
+
delete require.cache[key];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// Then require
|
|
171
|
+
return require(path);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Lazily compiled dynamic import loader function.
|
|
175
|
+
*/
|
|
176
|
+
let dynamicLoad;
|
|
177
|
+
function loadEsmModule(modulePath) {
|
|
178
|
+
const modulePathWithCacheBust = `${modulePath}?version=${Date.now()}`;
|
|
179
|
+
dynamicLoad ??= new Function('modulePath', `return import(modulePath);`);
|
|
180
|
+
return dynamicLoad(modulePathWithCacheBust);
|
|
181
|
+
}
|
|
182
|
+
exports.loadEsmModule = loadEsmModule;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addGitIgnoreEntry = void 0;
|
|
4
|
+
const ignore_1 = require("ignore");
|
|
5
|
+
function addGitIgnoreEntry(host) {
|
|
6
|
+
if (!host.exists('.gitignore')) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
let content = host.read('.gitignore', 'utf-8').trimEnd();
|
|
10
|
+
const ig = (0, ignore_1.default)();
|
|
11
|
+
ig.add(host.read('.gitignore', 'utf-8'));
|
|
12
|
+
if (!ig.ignores('apps/example/.next')) {
|
|
13
|
+
content = `${content}\n\n# Next.js\n.next\nout\n`;
|
|
14
|
+
}
|
|
15
|
+
host.write('.gitignore', content);
|
|
16
|
+
}
|
|
17
|
+
exports.addGitIgnoreEntry = addGitIgnoreEntry;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configureForSwc = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("./versions");
|
|
6
|
+
const add_swc_config_1 = require("@nx/js/src/utils/swc/add-swc-config");
|
|
7
|
+
function configureForSwc(tree, projectRoot) {
|
|
8
|
+
const swcConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, '.swcrc');
|
|
9
|
+
const rootPackageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
10
|
+
const hasSwcDepedency = rootPackageJson.dependencies?.['@swc/core'] ||
|
|
11
|
+
rootPackageJson.devDependencies?.['@swc/core'];
|
|
12
|
+
const hasSwcCliDependency = rootPackageJson.dependencies?.['@swc/cli'] ||
|
|
13
|
+
rootPackageJson.devDependencies?.['@swc/cli'];
|
|
14
|
+
if (!tree.exists(swcConfigPath)) {
|
|
15
|
+
(0, add_swc_config_1.addSwcConfig)(tree, projectRoot);
|
|
16
|
+
}
|
|
17
|
+
if (tree.exists(swcConfigPath)) {
|
|
18
|
+
(0, devkit_1.updateJson)(tree, swcConfigPath, (json) => {
|
|
19
|
+
return {
|
|
20
|
+
...json,
|
|
21
|
+
exclude: [...json.exclude, '.*.d.ts$'],
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (!hasSwcDepedency || !hasSwcCliDependency) {
|
|
26
|
+
addSwcDependencies(tree);
|
|
27
|
+
return () => (0, devkit_1.installPackagesTask)(tree);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.configureForSwc = configureForSwc;
|
|
31
|
+
function addSwcDependencies(tree) {
|
|
32
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
33
|
+
'@swc-node/register': versions_1.swcNodeVersion,
|
|
34
|
+
'@swc/cli': versions_1.swcCliVersion,
|
|
35
|
+
'@swc/core': versions_1.swcCoreVersion,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.composePlugins = void 0;
|
|
4
|
+
function composePlugins(...plugins) {
|
|
5
|
+
return function (baseConfig) {
|
|
6
|
+
return async function combined(phase, context) {
|
|
7
|
+
let config = baseConfig;
|
|
8
|
+
for (const plugin of plugins) {
|
|
9
|
+
const fn = await plugin;
|
|
10
|
+
const configOrFn = fn(config);
|
|
11
|
+
if (typeof configOrFn === 'function') {
|
|
12
|
+
config = await configOrFn(phase, context);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
config = configOrFn;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return config;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.composePlugins = composePlugins;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = () => { };
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = 'BAD';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NextConfig } from 'next';
|
|
2
|
+
import { Configuration } from 'webpack';
|
|
3
|
+
import { FileReplacement } from './types';
|
|
4
|
+
export interface NextConfigFn {
|
|
5
|
+
(phase: string, context?: any): Promise<NextConfig> | NextConfig;
|
|
6
|
+
}
|
|
7
|
+
export interface NextPlugin {
|
|
8
|
+
(config: NextConfig): NextConfig;
|
|
9
|
+
}
|
|
10
|
+
export interface NextPluginThatReturnsConfigFn {
|
|
11
|
+
(config: NextConfig): NextConfigFn;
|
|
12
|
+
}
|
|
13
|
+
export declare function createWebpackConfig(workspaceRoot: string, projectRoot: string, fileReplacements?: FileReplacement[], assets?: any): (a: any, b: any) => Configuration;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWebpackConfig = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const create_copy_plugin_1 = require("./create-copy-plugin");
|
|
6
|
+
function createWebpackConfig(workspaceRoot, projectRoot, fileReplacements = [], assets = null) {
|
|
7
|
+
return function webpackConfig(config, { isServer, }) {
|
|
8
|
+
fileReplacements
|
|
9
|
+
.map((fileReplacement) => ({
|
|
10
|
+
replace: (0, path_1.resolve)(workspaceRoot, fileReplacement.replace),
|
|
11
|
+
with: (0, path_1.resolve)(workspaceRoot, fileReplacement.with),
|
|
12
|
+
}))
|
|
13
|
+
.reduce((alias, replacement) => {
|
|
14
|
+
alias[replacement.replace] = replacement.with;
|
|
15
|
+
return alias;
|
|
16
|
+
}, config.resolve.alias);
|
|
17
|
+
// Copy (shared) assets to `public` folder during client-side compilation
|
|
18
|
+
if (!isServer && Array.isArray(assets) && assets.length > 0) {
|
|
19
|
+
config.plugins.push((0, create_copy_plugin_1.createCopyPlugin)(assets, workspaceRoot, projectRoot));
|
|
20
|
+
}
|
|
21
|
+
return config;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.createWebpackConfig = createWebpackConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'next/dist/shared/lib/constants';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createCliOptions(obj: Record<string, string | number | boolean>): string[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCliOptions = void 0;
|
|
4
|
+
function createCliOptions(obj) {
|
|
5
|
+
return Object.entries(obj).reduce((arr, [key, value]) => {
|
|
6
|
+
if (value !== undefined) {
|
|
7
|
+
const kebabCase = key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());
|
|
8
|
+
arr.push(`--${kebabCase}=${value}`);
|
|
9
|
+
}
|
|
10
|
+
return arr;
|
|
11
|
+
}, []);
|
|
12
|
+
}
|
|
13
|
+
exports.createCliOptions = createCliOptions;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCopyPlugin = void 0;
|
|
4
|
+
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
5
|
+
const path_1 = require("nx/src/utils/path");
|
|
6
|
+
const path_2 = require("path");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
function normalizeAssets(assets, root, sourceRoot) {
|
|
9
|
+
return assets.map((asset) => {
|
|
10
|
+
if (typeof asset === 'string') {
|
|
11
|
+
const assetPath = (0, path_1.normalizePath)(asset);
|
|
12
|
+
const resolvedAssetPath = (0, path_2.resolve)(root, assetPath);
|
|
13
|
+
const resolvedSourceRoot = (0, path_2.resolve)(root, sourceRoot);
|
|
14
|
+
if (!resolvedAssetPath.startsWith(resolvedSourceRoot)) {
|
|
15
|
+
throw new Error(`The ${resolvedAssetPath} asset path must start with the project source root: ${sourceRoot}`);
|
|
16
|
+
}
|
|
17
|
+
const isDirectory = (0, fs_1.statSync)(resolvedAssetPath).isDirectory();
|
|
18
|
+
const input = isDirectory
|
|
19
|
+
? resolvedAssetPath
|
|
20
|
+
: (0, path_2.dirname)(resolvedAssetPath);
|
|
21
|
+
const output = (0, path_2.relative)(resolvedSourceRoot, (0, path_2.resolve)(root, input));
|
|
22
|
+
const glob = isDirectory ? '**/*' : (0, path_2.basename)(resolvedAssetPath);
|
|
23
|
+
return {
|
|
24
|
+
input,
|
|
25
|
+
output,
|
|
26
|
+
glob,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
if (asset.output.startsWith('..')) {
|
|
31
|
+
throw new Error('An asset cannot be written to a location outside of the output path.');
|
|
32
|
+
}
|
|
33
|
+
const assetPath = (0, path_1.normalizePath)(asset.input);
|
|
34
|
+
const resolvedAssetPath = (0, path_2.resolve)(root, assetPath);
|
|
35
|
+
return {
|
|
36
|
+
...asset,
|
|
37
|
+
input: resolvedAssetPath,
|
|
38
|
+
// Now we remove starting slash to make Webpack place it from the output root.
|
|
39
|
+
output: asset.output.replace(/^\//, ''),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function createCopyPlugin(assets, root, sourceRoot) {
|
|
45
|
+
return new CopyWebpackPlugin({
|
|
46
|
+
patterns: normalizeAssets(assets, root, sourceRoot).map((asset) => {
|
|
47
|
+
return {
|
|
48
|
+
context: asset.input,
|
|
49
|
+
to: (0, path_2.join)('../public', asset.output),
|
|
50
|
+
from: asset.glob,
|
|
51
|
+
globOptions: {
|
|
52
|
+
ignore: [
|
|
53
|
+
'.gitkeep',
|
|
54
|
+
'**/.DS_Store',
|
|
55
|
+
'**/Thumbs.db',
|
|
56
|
+
...(asset.ignore ?? []),
|
|
57
|
+
],
|
|
58
|
+
dot: true,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exports.createCopyPlugin = createCopyPlugin;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createGlobPatternsOfDependentProjects = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const devkit_2 = require("@nx/devkit");
|
|
6
|
+
const project_graph_utils_1 = require("nx/src/utils/project-graph-utils");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
/**
|
|
9
|
+
* Use createGlobPatterns instead
|
|
10
|
+
* @deprecated Use createGlobPatternsForDependencies instead
|
|
11
|
+
*/
|
|
12
|
+
function createGlobPatternsOfDependentProjects(projectName, fileGlobPattern = '/**/!(*.stories|*.spec).tsx') {
|
|
13
|
+
devkit_1.logger.warn(`createGlobPatternsOfDependentProjects is deprecated. Use "createGlobPatternsForDependencies(__dirname)" from "@nx/next/tailwind" instead`);
|
|
14
|
+
try {
|
|
15
|
+
const [projectDirs, warnings] = (0, project_graph_utils_1.getSourceDirOfDependentProjects)(projectName);
|
|
16
|
+
if (warnings.length > 0) {
|
|
17
|
+
devkit_1.logger.warn(`
|
|
18
|
+
[createGlobPatternsForDependencies] Failed to generate glob pattern for the following:
|
|
19
|
+
${warnings.join('\n- ')}\n
|
|
20
|
+
due to missing "sourceRoot" in the dependencies' project configuration
|
|
21
|
+
`);
|
|
22
|
+
}
|
|
23
|
+
return projectDirs.map((sourceDir) => (0, path_1.resolve)(devkit_2.workspaceRoot, (0, devkit_1.joinPathFragments)(sourceDir, fileGlobPattern)));
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
throw new Error(`createGlobPatternsOfDependentProjects: Error when generating globs: ${e?.message}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.createGlobPatternsOfDependentProjects = createGlobPatternsOfDependentProjects;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
export declare const nextSpecificStyleDependenciesBabel: {
|
|
3
|
+
'styled-components': {
|
|
4
|
+
dependencies: import("../../../../build/packages/react/src/utils/dependencies").DependencyEntries;
|
|
5
|
+
devDependencies: {
|
|
6
|
+
'babel-plugin-styled-components': string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
'@emotion/styled': {
|
|
10
|
+
dependencies: {
|
|
11
|
+
'@emotion/server': string;
|
|
12
|
+
};
|
|
13
|
+
devDependencies: import("../../../../build/packages/react/src/utils/dependencies").DependencyEntries;
|
|
14
|
+
};
|
|
15
|
+
css: {
|
|
16
|
+
dependencies: {};
|
|
17
|
+
devDependencies: {};
|
|
18
|
+
};
|
|
19
|
+
scss: {
|
|
20
|
+
dependencies: {};
|
|
21
|
+
devDependencies: {
|
|
22
|
+
sass: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
less: {
|
|
26
|
+
dependencies: {};
|
|
27
|
+
devDependencies: {
|
|
28
|
+
less: string;
|
|
29
|
+
'less-loader': string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export declare const nextSpecificStyleDependenciesSwc: {
|
|
34
|
+
'styled-components': {
|
|
35
|
+
dependencies: import("../../../../build/packages/react/src/utils/dependencies").DependencyEntries;
|
|
36
|
+
devDependencies: {
|
|
37
|
+
'babel-plugin-styled-components': string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
'@emotion/styled': {
|
|
41
|
+
dependencies: {
|
|
42
|
+
'@emotion/server': string;
|
|
43
|
+
};
|
|
44
|
+
devDependencies: import("../../../../build/packages/react/src/utils/dependencies").DependencyEntries;
|
|
45
|
+
};
|
|
46
|
+
css: {
|
|
47
|
+
dependencies: {};
|
|
48
|
+
devDependencies: {};
|
|
49
|
+
};
|
|
50
|
+
scss: {
|
|
51
|
+
dependencies: {};
|
|
52
|
+
devDependencies: {
|
|
53
|
+
sass: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
less: {
|
|
57
|
+
dependencies: {};
|
|
58
|
+
devDependencies: {
|
|
59
|
+
less: string;
|
|
60
|
+
'less-loader': string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export declare function addStyleDependencies(host: Tree, options: {
|
|
65
|
+
style?: string;
|
|
66
|
+
swc?: boolean;
|
|
67
|
+
}): GeneratorCallback;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addStyleDependencies = exports.nextSpecificStyleDependenciesSwc = exports.nextSpecificStyleDependenciesBabel = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("@nx/react/src/utils/versions");
|
|
6
|
+
const styled_1 = require("@nx/react/src/utils/styled");
|
|
7
|
+
const versions_2 = require("./versions");
|
|
8
|
+
const nextSpecificStyleDependenciesCommon = {
|
|
9
|
+
css: {
|
|
10
|
+
dependencies: {},
|
|
11
|
+
devDependencies: {},
|
|
12
|
+
},
|
|
13
|
+
scss: {
|
|
14
|
+
dependencies: {},
|
|
15
|
+
devDependencies: { sass: versions_2.sassVersion },
|
|
16
|
+
},
|
|
17
|
+
less: {
|
|
18
|
+
dependencies: {},
|
|
19
|
+
devDependencies: {
|
|
20
|
+
less: versions_1.lessVersion,
|
|
21
|
+
'less-loader': versions_2.lessLoader,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
exports.nextSpecificStyleDependenciesBabel = {
|
|
26
|
+
...nextSpecificStyleDependenciesCommon,
|
|
27
|
+
'styled-components': {
|
|
28
|
+
dependencies: styled_1.cssInJsDependenciesBabel['styled-components'].dependencies,
|
|
29
|
+
devDependencies: {
|
|
30
|
+
...styled_1.cssInJsDependenciesBabel['styled-components'].devDependencies,
|
|
31
|
+
'babel-plugin-styled-components': versions_2.babelPluginStyledComponentsVersion,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
'@emotion/styled': {
|
|
35
|
+
dependencies: {
|
|
36
|
+
...styled_1.cssInJsDependenciesBabel['@emotion/styled'].dependencies,
|
|
37
|
+
'@emotion/server': versions_2.emotionServerVersion,
|
|
38
|
+
},
|
|
39
|
+
devDependencies: styled_1.cssInJsDependenciesBabel['@emotion/styled'].devDependencies,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
exports.nextSpecificStyleDependenciesSwc = {
|
|
43
|
+
...nextSpecificStyleDependenciesCommon,
|
|
44
|
+
'styled-components': {
|
|
45
|
+
dependencies: styled_1.cssInJsDependenciesSwc['styled-components'].dependencies,
|
|
46
|
+
devDependencies: {
|
|
47
|
+
...styled_1.cssInJsDependenciesSwc['styled-components'].devDependencies,
|
|
48
|
+
'babel-plugin-styled-components': versions_2.babelPluginStyledComponentsVersion,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
'@emotion/styled': {
|
|
52
|
+
dependencies: {
|
|
53
|
+
...styled_1.cssInJsDependenciesSwc['@emotion/styled'].dependencies,
|
|
54
|
+
'@emotion/server': versions_2.emotionServerVersion,
|
|
55
|
+
},
|
|
56
|
+
devDependencies: styled_1.cssInJsDependenciesSwc['@emotion/styled'].devDependencies,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
function addStyleDependencies(host, options) {
|
|
60
|
+
const extraDependencies = options.swc
|
|
61
|
+
? exports.nextSpecificStyleDependenciesSwc[options.style]
|
|
62
|
+
: exports.nextSpecificStyleDependenciesBabel[options.style];
|
|
63
|
+
return extraDependencies
|
|
64
|
+
? (0, devkit_1.addDependenciesToPackageJson)(host, extraDependencies.dependencies, extraDependencies.devDependencies)
|
|
65
|
+
: () => { };
|
|
66
|
+
}
|
|
67
|
+
exports.addStyleDependencies = addStyleDependencies;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type NextServer = (options: NextServerOptions, proxyConfig?: ProxyConfig) => Promise<void>;
|
|
2
|
+
export interface ProxyConfig {
|
|
3
|
+
[path: string]: {
|
|
4
|
+
target: string;
|
|
5
|
+
pathRewrite?: any;
|
|
6
|
+
changeOrigin?: boolean;
|
|
7
|
+
secure?: boolean;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface NextServerOptions {
|
|
11
|
+
dev: boolean;
|
|
12
|
+
dir: string;
|
|
13
|
+
staticMarkup: boolean;
|
|
14
|
+
quiet: boolean;
|
|
15
|
+
port: number;
|
|
16
|
+
hostname: string;
|
|
17
|
+
customServer?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface FileReplacement {
|
|
20
|
+
replace: string;
|
|
21
|
+
with: string;
|
|
22
|
+
}
|
|
23
|
+
export interface NextBuildBuilderOptions {
|
|
24
|
+
outputPath: string;
|
|
25
|
+
fileReplacements: FileReplacement[];
|
|
26
|
+
assets?: any[];
|
|
27
|
+
nextConfig?: string;
|
|
28
|
+
buildLibsFromSource?: boolean;
|
|
29
|
+
includeDevDependenciesInPackageJson?: boolean;
|
|
30
|
+
generateLockfile?: boolean;
|
|
31
|
+
watch?: boolean;
|
|
32
|
+
debug?: boolean;
|
|
33
|
+
profile?: boolean;
|
|
34
|
+
experimentalAppOnly?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface NextServeBuilderOptions {
|
|
37
|
+
dev: boolean;
|
|
38
|
+
port: number;
|
|
39
|
+
staticMarkup: boolean;
|
|
40
|
+
quiet: boolean;
|
|
41
|
+
buildTarget: string;
|
|
42
|
+
customServerTarget?: string;
|
|
43
|
+
hostname?: string;
|
|
44
|
+
buildLibsFromSource?: boolean;
|
|
45
|
+
keepAliveTimeout?: number;
|
|
46
|
+
turbo?: boolean;
|
|
47
|
+
experimentalHttps?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface NextExportBuilderOptions {
|
|
50
|
+
buildTarget: string;
|
|
51
|
+
silent: boolean;
|
|
52
|
+
threads: number;
|
|
53
|
+
buildLibsFromSource?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface WebpackConfigOptions {
|
|
56
|
+
svgr?: boolean;
|
|
57
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const nxVersion: any;
|
|
2
|
+
export declare const nextVersion = "14.0.4";
|
|
3
|
+
export declare const eslintConfigNextVersion = "14.0.4";
|
|
4
|
+
export declare const sassVersion = "1.62.1";
|
|
5
|
+
export declare const lessLoader = "11.1.0";
|
|
6
|
+
export declare const emotionServerVersion = "11.11.0";
|
|
7
|
+
export declare const babelPluginStyledComponentsVersion = "1.10.7";
|
|
8
|
+
export declare const tsLibVersion = "^2.3.0";
|
|
9
|
+
export declare const swcCliVersion = "~0.1.62";
|
|
10
|
+
export declare const swcCoreVersion = "~1.3.85";
|
|
11
|
+
export declare const swcHelpersVersion = "~0.5.2";
|
|
12
|
+
export declare const swcNodeVersion = "~1.8.0";
|