Skip to content

[Bug]: Panic Cannot get final name for export when using webpack.externals #10361

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

Open
ikscoder opened this issue May 14, 2025 · 3 comments
Open

Comments

@ikscoder
Copy link

ikscoder commented May 14, 2025

System Info

System:
OS: Windows 10 10.0.19043
CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
Memory: 35.89 GB / 63.93 GB
Binaries:
Node: 22.14.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
npm: 10.8.3 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 136.0.7103.93

@rspack/cli: 1.3.10
@rspack/core: 1.3.10

Details

When i define externals (e.g. pinia) build failed with:

Message:  Cannot get final name for export 'defineStore' 
Location: crates\rspack_core\src\concatenated_module.rs:2206

In webpack this configuration worked. For now I commented out some of the dependencies(not all cause panic), because it is not critical in my case.

Example rspack.config.ts if it is useful

import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
import {
	CopyRspackPlugin as CopyPlugin,
	DefinePlugin,
	CssExtractRspackPlugin as MiniCssExtractPlugin,
} from '@rspack/core';
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
import ESLintPlugin from 'eslint-rspack-plugin';
import path from 'path';
import StylelintPlugin from 'stylelint-webpack-plugin';
import { TsCheckerRspackPlugin } from 'ts-checker-rspack-plugin';
import { VueLoaderPlugin } from 'vue-loader';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
import WebpackBar from 'webpackbar/rspack';
import { defaultPackOptions, rules } from '../../configs/rspack.config.base';

module.exports = (
	env: Record<string, boolean>,
	{ mode }: { mode: 'development' | 'production' } = { mode: 'production' },
): import('@rspack/core').Configuration => (
	{
		...defaultPackOptions(),
		mode,
		entry: { components: './components/index.ts', directives: './directives/index.ts' },
		output: {
			path: path.resolve(__dirname, 'dist'),
			publicPath: 'auto',
			filename: `ui/[name]/index.js`,
		},
		externals: [
			//...internal packages
			'vue',
			'vue-router', // <---  this failed
			'luxon',
			'lodash',
			'pinia', // <--- this failed
			'dexie',
		].reduce(
			(acc, cur) =>
				Object.assign(acc, {
					[cur]: { commonjs: cur, commonjs2: cur, amd: cur },
				}),
			{},
		),
		node: {
			__filename: true,
		},
		resolve: {
			alias: {
				vue: 'vue/dist/vue.runtime.esm-bundler.js',
			},
			extensions: ['.json', '.ts', '.js'],
		},
		module: {
			rules: rules(mode),
		},
		plugins: [
			env.BUNDLE_ANALYTICS && new RsdoctorRspackPlugin({}),
			new WebpackBar(),
			new VueLoaderPlugin(),
			new TsCheckerRspackPlugin(),
			new ESLintPlugin({
				extensions: ['ts', 'vue', 'js'],
				configType: 'flat',
				overrideConfigFile: path.resolve(__dirname, '../../configs/.eslintrc.base.mjs'),
			}),
			new StylelintPlugin({
				files: ['**/*.{vue,scss}'],
				configFile: path.resolve(__dirname, '../../configs/.stylelintrc.base.json'),
			}),
			new DefinePlugin({
				__VUE_OPTIONS_API__: true,
				__VUE_PROD_DEVTOOLS__: false,
				__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false,
			}),
			new MiniCssExtractPlugin({ filename: `ui/[name]/index.css` }),
			new CopyPlugin({ patterns: [{ from: 'package.json', to: './ui/package.json' }] }),

			env.BUNDLE_ANALYTICS &&
				new BundleAnalyzerPlugin({
					analyzerMode: 'static',
					reportFilename: '../../analytics/#host-bundle-report.html',
				}),
			mode !== 'production' && new CaseSensitivePathsPlugin(),
		].filter(Boolean),
	}
);

Reproduce link

No response

Reproduce Steps

  1. npm create rspack@latest
  2. npm i pinia
  3. add to rspack.config.ts
	externals: [
		'vue',
		'pinia',
	].reduce(
		(acc, cur) =>
			Object.assign(acc, {
				[cur]: { commonjs: cur, commonjs2: cur, amd: cur },
			}),
		{},
	),
  1. add to main.ts
import { defineStore } from 'pinia';
export const useAppStore = defineStore('app', () => { return {} })
  1. build
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 'defineComponent' 
Location: crates\rspack_core\src\concatenated_module.rs:2206 
@ikscoder ikscoder added the pending triage The issue/PR is currently untouched. label May 14, 2025
@jkovar-acmark
Copy link

I have a similar issue with random error when building:

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 'easeCubicInOut'
Location: crates/rspack_core/src/concatenated_module.rs:2206

most likely from plotly.js or d3-ease

@rsbuild/core: 1.3.20
macos 15.4

@LingyuCoder LingyuCoder added need reproduction and removed pending triage The issue/PR is currently untouched. labels May 23, 2025
Copy link
Contributor

Hello @ikscoder, sorry we can't investigate the problem further without reproduction demo, please provide a repro demo by forking rspack-repro, or provide a minimal GitHub repository by yourself. Issues labeled by need reproduction will be closed if no activities in 14 days.

@LingyuCoder
Copy link
Contributor

Could you provide a repro? Problems of module concatenation are usually complex. It's hard to troubleshoot without a repro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants