Skip to content
Open
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
7 changes: 2 additions & 5 deletions e2e/nx-forge-e2e/tests/application.generator.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
checkFilesExist,
ensureNxProject,
readJson,
} from '@nx/plugin/testing';
import { checkFilesExist, ensureNxProject, readJson } from '@nx/plugin/testing';
import { generateForgeApp } from './utils/generate-forge-app';
import { ensureCorrectWorkspaceRoot } from './utils/e2e-workspace';
import { runNxCommandAsync } from './utils/async-commands';
Expand All @@ -29,6 +25,7 @@ describe('Forge application generator', () => {
checkFilesExist(`apps/${appName}/webpack.config.js`)
).not.toThrow();
expect(() => checkFilesExist(`apps/${appName}/src/index.ts`)).not.toThrow();
expect(() => checkFilesExist(`apps/${appName}/src/main.ts`)).toThrow();
});

describe('--directory', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ const { join } = require('path');

module.exports = {
output: {
path: join(__dirname, '<%= offset %><%= webpackPluginOptions.outputPath %>'),
library: {
type: 'commonjs2',
},
filename: 'index.js',
},
plugins: [
new NxAppWebpackPlugin({
target: 'node',
compiler: 'tsc',
outputPath: '<%= offset %><%= webpackPluginOptions.outputPath %>/src',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Drop the extra src suffix from outputPath.

webpackPluginOptions.outputPath is already built as dist/<app>/src in packages/nx-forge/src/generators/application/lib/add-app-files.ts:26-38, so Line 13 turns it into dist/.../src/src. That moves the bundle out of the location expected by the tunnel flow in packages/nx-forge/src/executors/tunnel/lib/run-tunnel.ts:23-37 and breaks the generated app layout.

💡 Proposed fix
-      outputPath: '<%= offset %><%= webpackPluginOptions.outputPath %>/src',
+      outputPath: '<%= offset %><%= webpackPluginOptions.outputPath %>',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
outputPath: '<%= offset %><%= webpackPluginOptions.outputPath %>/src',
outputPath: '<%= offset %><%= webpackPluginOptions.outputPath %>',
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/nx-forge/src/generators/application/files/webpack.config.js__tmpl__`
at line 13, The outputPath currently appends an extra '/src' causing double
'.../src/src' because webpackPluginOptions.outputPath already contains
'dist/<app>/src'; update the webpack config line that sets outputPath (the one
referencing webpackPluginOptions.outputPath) to remove the hard-coded '/src'
suffix so it uses just '<%= offset %><%= webpackPluginOptions.outputPath %>';
this will restore the expected layout used by the tunnel flow (see run-tunnel
logic) and prevent the bundle being written to the wrong directory.

main: '<%= webpackPluginOptions.main %>',
outputFileName: 'index.js',
tsConfig: '<%= webpackPluginOptions.tsConfig %>',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ describe('application generator', () => {
expect(tree.exists(eslintConfigPath('my-forge-app'))).toBeTruthy();
expect(tree.exists('my-forge-app/manifest.yml')).toBeTruthy();
expect(tree.exists('my-forge-app/src/index.ts')).toBeTruthy();
expect(tree.exists('my-forge-app/src/main.ts')).toEqual(false);

const tsconfig = readJson(tree, 'my-forge-app/tsconfig.json');
expect(tsconfig).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -306,6 +307,8 @@ describe('application generator', () => {
expect(tree.exists(path)).toBeTruthy();
});

expect(tree.exists('my-dir/my-forge-app/src/main.ts')).toEqual(false);

const hasJsonValue = ({ path, expectedValue, lookupFn }) => {
const config = readJson(tree, path);
const actual = lookupFn(config);
Expand Down
Loading