Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(remix): add continuous task support #29905

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import {
readNxJson,
type ExpandedPluginConfiguration,
updateNxJson,
detectPackageManager,
} from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { TempFs } from '@nx/devkit/internal-testing-utils';
import { getRelativeProjectJsonSchemaPath } from 'nx/src/generators/utils/project-configuration';
import { join } from 'path';
import { convertToInferred } from './convert-to-inferred';
import { getLockFileName } from '@nx/js';

let fs: TempFs;
let projectGraph: ProjectGraph;
Expand Down Expand Up @@ -165,7 +167,9 @@ describe('Remix - Convert To Inferred', () => {
fs = new TempFs('remix');
tree = createTreeWithEmptyWorkspace();
tree.root = fs.tempDir;

const lockFileName = getLockFileName(detectPackageManager(fs.tempDir));
fs.createFileSync(lockFileName, '');
tree.write(lockFileName, '');
projectGraph = {
nodes: {},
dependencies: {},
Expand Down
20 changes: 20 additions & 0 deletions packages/remix/src/plugins/__snapshots__/plugin.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ exports[`@nx/remix/plugin Remix Classic Compiler non-root project should create
},
"dev": {
"command": "remix dev --manual",
"continuous": true,
"options": {
"cwd": "my-app",
},
},
"serve-static": {
"command": "remix-serve build/index.js",
"continuous": true,
"dependsOn": [
"build",
],
Expand All @@ -55,6 +57,7 @@ exports[`@nx/remix/plugin Remix Classic Compiler non-root project should create
},
"start": {
"command": "remix-serve build/index.js",
"continuous": true,
"dependsOn": [
"build",
],
Expand All @@ -64,6 +67,7 @@ exports[`@nx/remix/plugin Remix Classic Compiler non-root project should create
},
"static-serve": {
"command": "remix-serve build/index.js",
"continuous": true,
"dependsOn": [
"build",
],
Expand Down Expand Up @@ -155,12 +159,14 @@ exports[`@nx/remix/plugin Remix Classic Compiler non-root project should infer w
},
"dev": {
"command": "remix dev --manual",
"continuous": true,
"options": {
"cwd": "my-app",
},
},
"serve-static": {
"command": "remix-serve build/index.js",
"continuous": true,
"dependsOn": [
"build",
],
Expand All @@ -170,6 +176,7 @@ exports[`@nx/remix/plugin Remix Classic Compiler non-root project should infer w
},
"start": {
"command": "remix-serve build/index.js",
"continuous": true,
"dependsOn": [
"build",
],
Expand All @@ -179,6 +186,7 @@ exports[`@nx/remix/plugin Remix Classic Compiler non-root project should infer w
},
"static-serve": {
"command": "remix-serve build/index.js",
"continuous": true,
"dependsOn": [
"build",
],
Expand Down Expand Up @@ -265,12 +273,14 @@ exports[`@nx/remix/plugin Remix Classic Compiler root project should create node
},
"dev": {
"command": "remix dev --manual",
"continuous": true,
"options": {
"cwd": ".",
},
},
"serve-static": {
"command": "remix-serve build/index.js",
"continuous": true,
"dependsOn": [
"build",
],
Expand All @@ -280,6 +290,7 @@ exports[`@nx/remix/plugin Remix Classic Compiler root project should create node
},
"start": {
"command": "remix-serve build/index.js",
"continuous": true,
"dependsOn": [
"build",
],
Expand All @@ -289,6 +300,7 @@ exports[`@nx/remix/plugin Remix Classic Compiler root project should create node
},
"static-serve": {
"command": "remix-serve build/index.js",
"continuous": true,
"dependsOn": [
"build",
],
Expand Down Expand Up @@ -373,12 +385,14 @@ exports[`@nx/remix/plugin Remix Vite Compiler non-root project should create nod
},
"dev": {
"command": "remix vite:dev",
"continuous": true,
"options": {
"cwd": "my-app",
},
},
"serve-static": {
"command": "remix-serve build/server/index.js",
"continuous": true,
"dependsOn": [
"build",
],
Expand All @@ -388,6 +402,7 @@ exports[`@nx/remix/plugin Remix Vite Compiler non-root project should create nod
},
"start": {
"command": "remix-serve build/server/index.js",
"continuous": true,
"dependsOn": [
"build",
],
Expand All @@ -397,6 +412,7 @@ exports[`@nx/remix/plugin Remix Vite Compiler non-root project should create nod
},
"static-serve": {
"command": "remix-serve build/server/index.js",
"continuous": true,
"dependsOn": [
"build",
],
Expand Down Expand Up @@ -482,12 +498,14 @@ exports[`@nx/remix/plugin Remix Vite Compiler root project should create nodes 1
},
"dev": {
"command": "remix vite:dev",
"continuous": true,
"options": {
"cwd": ".",
},
},
"serve-static": {
"command": "remix-serve build/server/index.js",
"continuous": true,
"dependsOn": [
"build",
],
Expand All @@ -497,6 +515,7 @@ exports[`@nx/remix/plugin Remix Vite Compiler root project should create nodes 1
},
"start": {
"command": "remix-serve build/server/index.js",
"continuous": true,
"dependsOn": [
"build",
],
Expand All @@ -506,6 +525,7 @@ exports[`@nx/remix/plugin Remix Vite Compiler root project should create nodes 1
},
"static-serve": {
"command": "remix-serve build/server/index.js",
"continuous": true,
"dependsOn": [
"build",
],
Expand Down
26 changes: 24 additions & 2 deletions packages/remix/src/plugins/plugin.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { type CreateNodesContext, joinPathFragments } from '@nx/devkit';
import {
type CreateNodesContext,
detectPackageManager,
joinPathFragments,
} from '@nx/devkit';
import { createNodesV2 as createNodes } from './plugin';
import { TempFs } from 'nx/src/internal-testing-utils/temp-fs';
import { loadViteDynamicImport } from '../utils/executor-utils';
import { isUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';
import { getLockFileName } from '@nx/js';

jest.mock('../utils/executor-utils', () => ({
loadViteDynamicImport: jest.fn().mockResolvedValue({
Expand Down Expand Up @@ -69,6 +74,10 @@ module.exports = {
};
`
);
const lockFileName = getLockFileName(
detectPackageManager(tempFs.tempDir)
);
tempFs.createFileSync(lockFileName, '');
process.chdir(tempFs.tempDir);
});

Expand Down Expand Up @@ -116,6 +125,10 @@ module.exports = {
'my-app/project.json',
JSON.stringify({ name: 'my-app' })
);
const lockFileName = getLockFileName(
detectPackageManager(tempFs.tempDir)
);
tempFs.createFileSync(lockFileName, '');

tempFs.createFileSync(
'my-app/remix.config.cjs',
Expand Down Expand Up @@ -221,7 +234,7 @@ module.exports = {
(isUsingTsSolutionSetup as jest.Mock).mockReturnValue(true);
tempFs.createFileSync(
'my-app/package.json',
JSON.stringify('{"name": "my-app"}')
JSON.stringify('{"name": "my-app", "version": "0.0.0"}')
);

const nodes = await createNodesFunction(
Expand Down Expand Up @@ -294,6 +307,10 @@ module.exports = {
'package.json',
JSON.stringify('{name: "my-app", type: "module"}')
);
const lockFileName = getLockFileName(
detectPackageManager(tempFs.tempDir)
);
tempFs.createFileSync(lockFileName, '');
tempFs.createFileSync(
'vite.config.js',
`const {defineConfig} = require('vite');
Expand Down Expand Up @@ -379,6 +396,11 @@ module.exports = {
}),
});

const lockFileName = getLockFileName(
detectPackageManager(tempFs.tempDir)
);
tempFs.createFileSync(lockFileName, '');

process.chdir(tempFs.tempDir);
});

Expand Down
2 changes: 2 additions & 0 deletions packages/remix/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ function devTarget(
isUsingTsSolutionSetup: boolean
): TargetConfiguration {
const devTarget: TargetConfiguration = {
continuous: true,
Coly010 marked this conversation as resolved.
Show resolved Hide resolved
command:
remixCompiler === RemixCompiler.IsVte
? 'remix vite:dev'
Expand Down Expand Up @@ -335,6 +336,7 @@ function startTarget(

const startTarget: TargetConfiguration = {
dependsOn: [buildTargetName],
continuous: true,
command: `remix-serve ${serverPath}`,
options: {
cwd: projectRoot,
Expand Down