Skip to content

Commit

Permalink
fix(rspack): fix rspack build
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz authored and juristr committed Mar 10, 2023
1 parent 18e3443 commit cab70e5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
10 changes: 10 additions & 0 deletions project.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@
"jestConfig": "packages/rspack/jest.config.ts",
"passWithNoTests": true
}
},
"publish": {
"executor": "nx:run-commands",
"options": {
"parallel": false,
"commands": [
"nx build rspack",
"node tools/scripts/publish.mjs rspack {args.ver} {args.tag}"
]
}
}
},
"tags": []
Expand Down
26 changes: 23 additions & 3 deletions src/executors/rspack/rspack.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,29 @@ export default async function runExecutor(
const compiler = await createCompiler(options, context);

return new Promise<{ success: boolean }>((res) => {
compiler.run(() => {
compiler.close((err: any) => {
res({ success: !err });
compiler.run((error, stats) => {
// OURS
compiler.close(() => {
if (error) {
console.error(error);
res({ success: false });
return;
}
if (!compiler || !stats) {
res({ success: false });
return;
}

// TODO: Handle MultipleCompiler
const statsOptions = compiler.options
? compiler.options.stats
: undefined;
const printedStats = stats.toString(statsOptions);
// Avoid extra empty line when `stats: 'none'`
if (printedStats) {
console.error(printedStats);
}
res({ success: !stats.hasErrors() });
});
});
});
Expand Down
6 changes: 5 additions & 1 deletion src/utils/with-nx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function withNx(_opts = {}) {
return acc;
}, {});

const updated = {
const updated: Configuration = {
...config,
target: options.target,
mode: 'development' as const,
Expand Down Expand Up @@ -96,6 +96,10 @@ export function withNx(_opts = {}) {
refresh: isDev,
},
},
stats: {
colors: true,
preset: 'normal'
}
};

if (options.optimization) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/with-web.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Configuration } from '@rspack/core';
import { ModuleRule } from '@rspack/core/dist/config/module';
import { RuleSetRule } from '@rspack/core';
import * as path from 'path';
import { SharedConfigContext } from './model';

Expand Down Expand Up @@ -95,7 +95,7 @@ export function withWeb(opts: WithWebOptions = {}) {
},
],
},
].filter((a): a is ModuleRule => !!a),
].filter((a): a is RuleSetRule => !!a),
},
builtins: {
...config.builtins,
Expand Down

0 comments on commit cab70e5

Please sign in to comment.