@nx/remix 19.7.2 → 19.8.0-beta.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/remix",
3
- "version": "19.7.2",
3
+ "version": "19.8.0-beta.0",
4
4
  "description": "The Remix plugin for Nx contains executors and generators for managing Remix applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Vitest, Jest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, routes, loaders, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,12 +29,12 @@
29
29
  "migrations": "./migrations.json"
30
30
  },
31
31
  "dependencies": {
32
- "@nx/devkit": "19.7.2",
33
- "@nx/js": "19.7.2",
34
- "@nx/react": "19.7.2",
32
+ "@nx/devkit": "19.8.0-beta.0",
33
+ "@nx/js": "19.8.0-beta.0",
34
+ "@nx/react": "19.8.0-beta.0",
35
35
  "tslib": "^2.3.1",
36
36
  "@phenomnomnominal/tsquery": "~5.0.1",
37
- "@nrwl/remix": "19.7.2"
37
+ "@nrwl/remix": "19.8.0-beta.0"
38
38
  },
39
39
  "peerDependencies": {},
40
40
  "publishConfig": {
@@ -329,8 +329,7 @@ export default {
329
329
  `;
330
330
 
331
331
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provided --unitTestRunner should generate the correct files for testing using jest 2`] = `
332
- "/* eslint-disable */
333
- export default {
332
+ "export default {
334
333
  displayName: 'test',
335
334
  preset: '../jest.preset.js',
336
335
  transform: {
@@ -846,8 +845,7 @@ export default {
846
845
  `;
847
846
 
848
847
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived --unitTestRunner should generate the correct files for testing using jest 2`] = `
849
- "/* eslint-disable */
850
- export default {
848
+ "export default {
851
849
  displayName: 'test',
852
850
  preset: '../../jest.preset.js',
853
851
  transform: {
@@ -1146,8 +1144,7 @@ export default {
1146
1144
  `;
1147
1145
 
1148
1146
  exports[`Remix Application Standalone Project Repo --unitTestRunner should generate the correct files for testing using jest 2`] = `
1149
- "/* eslint-disable */
1150
- export default {
1147
+ "export default {
1151
1148
  setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
1152
1149
  displayName: 'test',
1153
1150
  preset: './jest.preset.cjs',
@@ -1403,7 +1400,7 @@ exports[`Remix Application Standalone Project Repo should create the application
1403
1400
  exports[`Remix Application Standalone Project Repo should create the application correctly 6`] = `
1404
1401
  "{
1405
1402
  "root": true,
1406
- "ignorePatterns": ["!**/*"],
1403
+ "ignorePatterns": ["!**/*", "build", "public/build"],
1407
1404
  "plugins": ["@nx"],
1408
1405
  "overrides": [
1409
1406
  {
@@ -3,16 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.remixApplicationGenerator = remixApplicationGenerator;
4
4
  exports.remixApplicationGeneratorInternal = remixApplicationGeneratorInternal;
5
5
  const devkit_1 = require("@nx/devkit");
6
- const create_ts_config_1 = require("@nx/js/src/utils/typescript/create-ts-config");
7
- const versions_1 = require("../../utils/versions");
8
- const lib_1 = require("./lib");
9
- const update_dependencies_1 = require("../utils/update-dependencies");
10
- const init_1 = require("../init/init");
11
- const js_1 = require("@nx/js");
12
6
  const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
13
7
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
14
- const testing_config_utils_1 = require("../../utils/testing-config-utils");
8
+ const js_1 = require("@nx/js");
9
+ const create_ts_config_1 = require("@nx/js/src/utils/typescript/create-ts-config");
10
+ const node_path_1 = require("node:path");
15
11
  const onboarding_1 = require("nx/src/nx-cloud/utilities/onboarding");
12
+ const testing_config_utils_1 = require("../../utils/testing-config-utils");
13
+ const versions_1 = require("../../utils/versions");
14
+ const init_1 = require("../init/init");
15
+ const update_dependencies_1 = require("../utils/update-dependencies");
16
+ const lib_1 = require("./lib");
16
17
  function remixApplicationGenerator(tree, options) {
17
18
  return remixApplicationGeneratorInternal(tree, {
18
19
  addPlugin: false,
@@ -150,6 +151,7 @@ async function remixApplicationGeneratorInternal(tree, _options) {
150
151
  }
151
152
  if (options.linter !== 'none') {
152
153
  const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/eslint', (0, versions_1.getPackageVersion)(tree, 'nx'));
154
+ const { addIgnoresToLintConfig } = await Promise.resolve().then(() => require('@nx/eslint/src/generators/utils/eslint-file'));
153
155
  const eslintTask = await lintProjectGenerator(tree, {
154
156
  linter: options.linter,
155
157
  project: options.projectName,
@@ -162,8 +164,10 @@ async function remixApplicationGeneratorInternal(tree, _options) {
162
164
  addPlugin: options.addPlugin,
163
165
  });
164
166
  tasks.push(eslintTask);
165
- tree.write((0, devkit_1.joinPathFragments)(options.projectRoot, '.eslintignore'), (0, devkit_1.stripIndents) `build
166
- public/build`);
167
+ addIgnoresToLintConfig(tree, options.projectRoot, [
168
+ 'build',
169
+ 'public/build',
170
+ ]);
167
171
  }
168
172
  if (options.js) {
169
173
  (0, devkit_1.toJS)(tree);
@@ -211,6 +215,36 @@ export default {...nxPreset};
211
215
  }
212
216
  }
213
217
  tasks.push(await (0, lib_1.addE2E)(tree, options));
218
+ // If the project package.json uses type module, and the project uses flat eslint config, we need to make sure the eslint config uses an explicit .cjs extension
219
+ // TODO: This could be re-evaluated once we support ESM in eslint configs
220
+ if (tree.exists((0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json')) &&
221
+ tree.exists((0, devkit_1.joinPathFragments)(options.projectRoot, 'eslint.config.js'))) {
222
+ const pkgJson = (0, devkit_1.readJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'));
223
+ if (pkgJson.type === 'module') {
224
+ tree.rename((0, devkit_1.joinPathFragments)(options.projectRoot, 'eslint.config.js'), (0, devkit_1.joinPathFragments)(options.projectRoot, 'eslint.config.cjs'));
225
+ (0, devkit_1.visitNotIgnoredFiles)(tree, options.projectRoot, (file) => {
226
+ if (file.endsWith('eslint.config.js')) {
227
+ // Replace any extends on the eslint config to use the .cjs extension
228
+ const content = tree.read(file).toString();
229
+ if (content.includes('eslint.config')) {
230
+ tree.write(file, content
231
+ .replace(/eslint\.config'/g, `eslint.config.cjs'`)
232
+ .replace(/eslint\.config"/g, `eslint.config.cjs"`)
233
+ .replace(/eslint\.config\.js/g, `eslint.config.cjs`));
234
+ }
235
+ // If there is no sibling package.json with type commonjs, we need to rename the .js files to .cjs
236
+ const siblingPackageJsonPath = (0, devkit_1.joinPathFragments)((0, node_path_1.dirname)(file), 'package.json');
237
+ if (tree.exists(siblingPackageJsonPath)) {
238
+ const siblingPkgJson = (0, devkit_1.readJson)(tree, siblingPackageJsonPath);
239
+ if (siblingPkgJson.type === 'module') {
240
+ return;
241
+ }
242
+ }
243
+ tree.rename(file, file.replace('.js', '.cjs'));
244
+ }
245
+ });
246
+ }
247
+ }
214
248
  if (!options.skipFormat) {
215
249
  await (0, devkit_1.formatFiles)(tree);
216
250
  }
@@ -33,7 +33,7 @@ async function convertToInferred(tree, options) {
33
33
  },
34
34
  ], options.project);
35
35
  if (migratedProjects.size === 0) {
36
- throw new Error('Could not find any targets to migrate.');
36
+ throw new executor_to_plugin_migrator_1.NoTargetsToMigrateError();
37
37
  }
38
38
  if (!options.skipFormat) {
39
39
  await (0, devkit_1.formatFiles)(tree);
@@ -1,8 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`Remix Library Generator -projectNameAndRootFormat=as-provided --unitTestRunner should create the correct config files for testing with jest 1`] = `
4
- "/* eslint-disable */
5
- export default {
4
+ "export default {
6
5
  setupFilesAfterEnv: ['./src/test-setup.ts'],
7
6
  displayName: 'test',
8
7
  preset: '../jest.preset.js',
@@ -80,8 +79,7 @@ exports[`Remix Library Generator -projectNameAndRootFormat=as-provided should ge
80
79
  `;
81
80
 
82
81
  exports[`Remix Library Generator -projectNameAndRootFormat=derived --unitTestRunner should create the correct config files for testing with jest 1`] = `
83
- "/* eslint-disable */
84
- export default {
82
+ "export default {
85
83
  setupFilesAfterEnv: ['./src/test-setup.ts'],
86
84
  displayName: 'test',
87
85
  preset: '../../jest.preset.js',
@@ -24,7 +24,7 @@ const createDependencies = () => {
24
24
  return [];
25
25
  };
26
26
  exports.createDependencies = createDependencies;
27
- const remixConfigGlob = '**/{remix,vite}.config.{js,cjs,mjs}';
27
+ const remixConfigGlob = '**/{remix,vite}.config.{js,cjs,mjs,ts,cts,mts}';
28
28
  exports.createNodesV2 = [
29
29
  remixConfigGlob,
30
30
  async (configFilePaths, options, context) => {
@@ -206,9 +206,12 @@ function determineIsRemixVite(configFilePath, workspaceRoot) {
206
206
  if (configFilePath.includes('remix.config')) {
207
207
  return RemixCompiler.IsClassic;
208
208
  }
209
+ const VITE_PLUGIN_REGEX = /vitePlugin\(\s*(.|\n)*?\s*\)/;
210
+ const REMIX_PLUGIN_REGEX = /remix\(\s*(.|\n)*?\s*\)/;
209
211
  const fileContents = (0, fs_1.readFileSync)((0, path_1.join)(workspaceRoot, configFilePath), 'utf8');
210
212
  if (fileContents.includes('@remix-run/dev') &&
211
- (fileContents.includes('vitePlugin()') || fileContents.includes('remix()'))) {
213
+ (VITE_PLUGIN_REGEX.test(fileContents) ||
214
+ REMIX_PLUGIN_REGEX.test(fileContents))) {
212
215
  return RemixCompiler.IsVte;
213
216
  }
214
217
  else {