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

[Bug]: Panic when using persistent cache: Cannot get final name for export #9124

Open
Clarkkkk opened this issue Jan 26, 2025 · 0 comments
Open
Assignees
Labels
bug Something isn't working need reproduction

Comments

@Clarkkkk
Copy link

Clarkkkk commented Jan 26, 2025

System Info

System:
OS: macOS 14.7.2
CPU: (11) arm64 Apple M3 Pro
Memory: 90.56 MB / 18.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 23.6.0 - /opt/homebrew/bin/node
npm: 10.9.2 - /opt/homebrew/bin/npm
pnpm: 8.15.7 - /opt/homebrew/bin/pnpm
Browsers:
Chrome: 132.0.6834.110
Safari: 17.6
"@rsbuild/core": "^1.2.2",

Details

The first build is ok, but the second build with cache leads to panic. It says Cannot get final name for export 'isApp', isApp is a variable imported from a third party package. Since this project and the third party package is internal, i cannot provide reproduction right away. Maybe you can check the information below first. If it is not enough to locate the problem, please tell me and i am willing to make a reproduction.

My rsbuild.config.ts:

import { defineConfig, loadEnv } from '@rsbuild/core'
import { pluginLess } from '@rsbuild/plugin-less'
import { pluginReact } from '@rsbuild/plugin-react'
import { pluginSass } from '@rsbuild/plugin-sass'
import { pluginSvgr } from '@rsbuild/plugin-svgr'
import { pluginUmd } from '@rsbuild/plugin-umd'
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin'
import parseArgs from 'minimist'
import path from 'node:path'
import Icons from 'unplugin-icons/rspack'

const modePortMap = {
    dev: 8501,
}

const sourceMap = process.env.NODE_ENV === 'development' ? 'source-map' : false

function getProxyDomain(envMode: string): string {
    const args = parseArgs(process.argv.slice(2))

    const proxies = {
        dev: 'http://xxx.com/',
    } as Record<string, string>

    const key = `${args.country ? args.country + '-' : ''}${envMode}`

    return proxies[key]
}

export default defineConfig(({ envMode }) => {
    const { parsed: developEnv } = loadEnv()
    const { publicVars } = loadEnv({
        prefixes: ['APP_'],
        mode: envMode
    })

    console.log('NODE_ENV:', process.env.NODE_ENV)
    console.log({ envMode })
    console.log(publicVars)
    console.log('proxy domain: ', getProxyDomain(envMode || 'env'))

    const port =
        developEnv.DEVELOP_MODE === 'STANDALONE'
            ? modePortMap.alone
            : modePortMap[envMode as keyof typeof modePortMap]

    return {
        plugins: [
            pluginSvgr({
                svgrOptions: {
                    icon: true
                }
            }),
            pluginReact(),
            pluginSass({
                sassLoaderOptions: {
                    sassOptions: {
                        silenceDeprecations: ['mixed-decls']
                    }
                }
            }),
            pluginLess({
                lessLoaderOptions: {
                    lessOptions: {
                        math: 'always',
                        javascriptEnabled: true
                    }
                }
            }),
            pluginUmd({
                name: 'xxx'
            })
        ],
        dev: {
            assetPrefix:
                developEnv.DEVELOP_MODE === 'STANDALONE'
                    ? `http://localhost:${port}`
                    : `xxx`,
            progressBar: true
        },
        output: {
            assetPrefix: 'xxx',
            filenameHash: 'contenthash:8',
            polyfill: 'usage',
            sourceMap: {
                js: sourceMap,
                css: !!sourceMap
            }
        },
        server: {
            port,
            open: `http://localhost:${port}/`,
            headers: {
                'Access-Control-Allow-Origin': '*'
            },
            proxy:
                // prettier-ignore
                developEnv.DEVELOP_MODE === 'STANDALONE'
                    ? undefined
                    : {
                        '/': {
                            target: getProxyDomain(envMode || 'env'),
                            changeOrigin: true,
                            bypass: function (req: any) {
                                if (req.originalUrl.startsWith('xxx')) {
                                    return true // 不代理
                                }
                            }
                        }
                    }
        },
        source: {
            define: {
                ...publicVars
            },
            entry: {
                index: './src/main.js'
            }
        },
        html: {
            template: './index.html',
            scriptLoading: 'blocking',
            inject: 'body'
        },
        tools: {
            htmlPlugin: true,
            lightningcssLoader: {
                exclude: {
                    vendorPrefixes: false
                }
            },
            rspack: {
                devtool: sourceMap,
                output: {
                    // https://qiankun.umijs.org/zh/faq
                    globalObject: 'window'
                },
                plugins: [
                    Icons({
                        compiler: 'jsx',
                        jsx: 'react'
                    }),
                    process.env.RSDOCTOR &&
                        new RsdoctorRspackPlugin({
                            supports: {
                                generateTileGraph: true
                            }
                        })
                ].filter(Boolean),
                cache: true,
                experiments: {
                    incremental: true,
                    cache: {
                        type: 'persistent',
                        version: `cache-${envMode}`,
                        buildDependencies: [
                            __filename,
                            path.join(__dirname, 'package.json'),
                            path.join(__dirname, './tsconfig.json')
                        ]
                    }
                }
            }
        },
        performance: {
            removeMomentLocale: true,
            removeConsole: ['log']
        }
    }
})

The full error message:

Panic occurred at runtime. Please file an issue on GitHub with the backtrace below: https://github.com/web-infra-dev/rspack/issues
Message:  Cannot get final name for export 'isApp'
Location: crates/rspack_core/src/concatenated_module.rs:2207

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 1: _napi_register_module_v1
    at <unknown source file>
 2: _napi_register_module_v1
    at <unknown source file>
 3: _napi_register_module_v1
    at <unknown source file>
 4: _napi_register_module_v1
    at <unknown source file>
 5: _wasmer_vm_f64_nearest
    at <unknown source file>
 6: _napi_register_module_v1
    at <unknown source file>
 7: _napi_register_module_v1
    at <unknown source file>
 8: _napi_register_module_v1
    at <unknown source file>
 9: _napi_register_module_v1
    at <unknown source file>
10: _napi_register_module_v1
    at <unknown source file>
11: _napi_register_module_v1
    at <unknown source file>
12: _napi_register_module_v1
    at <unknown source file>
13: _napi_register_module_v1
    at <unknown source file>
14: _napi_register_module_v1
    at <unknown source file>
15: _napi_register_module_v1
    at <unknown source file>
16: _napi_register_module_v1
    at <unknown source file>
17: _napi_register_module_v1
    at <unknown source file>
18: _napi_register_module_v1
    at <unknown source file>
19: _napi_register_module_v1
    at <unknown source file>
20: _napi_register_module_v1
    at <unknown source file>
21: _wasmer_vm_f64_nearest
    at <unknown source file>
22: _napi_register_module_v1
    at <unknown source file>
23: _napi_register_module_v1
    at <unknown source file>
24: _napi_register_module_v1
    at <unknown source file>
25: __pthread_joiner_wake
    at <unknown source file>

Reproduce link

cannot provide currently

Reproduce Steps

none

@Clarkkkk Clarkkkk added bug Something isn't working pending triage The issue/PR is currently untouched. labels Jan 26, 2025
@chenjiahan chenjiahan added need reproduction and removed pending triage The issue/PR is currently untouched. labels Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need reproduction
Projects
None yet
Development

No branches or pull requests

3 participants