Skip to content

Commit

Permalink
fix: do not remove request config of dataLoader compilation (#6869)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClarkXia authored Apr 25, 2024
1 parent 5e3bed3 commit 5c40dc9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/odd-crews-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/app': patch
---

fix: do not remove request config of dataLoader compilation in speedup mode
2 changes: 1 addition & 1 deletion examples/with-request/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { request as requestAPI, defineDataLoader } from 'ice';
import { defineRequestConfig } from '@ice/plugin-request/types';

export const dataLader = defineDataLoader(async () => {
export const dataLoader = defineDataLoader(async () => {
try {
return await requestAPI('/user');
} catch (err) {
Expand Down
11 changes: 10 additions & 1 deletion packages/ice/src/bundler/rspack/getConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import { getReCompilePlugin, getServerPlugin, getSpinnerPlugin } from '../config/plugins.js';
import { getExpandedEnvs } from '../../utils/runtimeEnv.js';
import type { BundlerOptions, Context } from '../types.js';
import type { PluginData } from '../../types/plugin.js';

type GetConfig = (
context: Context,
Expand Down Expand Up @@ -94,9 +95,17 @@ export const getDataLoaderConfig: GetDataLoaderRspackConfig = async (context, ta
extendsPluginAPI: {
generator,
},
getAllPlugin,
} = context;
const { config } = task;
const frameworkExports = generator.getExportList('framework', config.target);
const plugins = getAllPlugin(['keepExports']) as PluginData[];
let keepExports = ['dataLoader'];
plugins.forEach(plugin => {
if (plugin.keepExports) {
keepExports = keepExports.concat(plugin.keepExports);
}
});
return await getRspackConfig({
rootDir,
rspack,
Expand All @@ -115,7 +124,7 @@ export const getDataLoaderConfig: GetDataLoaderRspackConfig = async (context, ta
'data-loader': path.join(rootDir, RUNTIME_TMP_DIR, 'data-loader.ts'),
},
swcOptions: {
keepExports: ['dataLoader'],
keepExports,
},
splitChunks: false,
redirectImports: frameworkExports,
Expand Down

0 comments on commit 5c40dc9

Please sign in to comment.