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

[Feature]: module-import Support setting aliases #8326

Open
lzxb opened this issue Nov 4, 2024 · 2 comments
Open

[Feature]: module-import Support setting aliases #8326

lzxb opened this issue Nov 4, 2024 · 2 comments
Labels
feat New feature or request pending triage The issue/PR is currently untouched.

Comments

@lzxb
Copy link
Contributor

lzxb commented Nov 4, 2024

What problem does this feature solve?

I am designing an ESM (ECMAScript Module) module linking with the intention of exporting multiple packages within a single file to reduce HTTP requests. When importing, aliases will be specified.

What does the proposed API of configuration look like?

Consolidate export files.

ssr-base/vue.ts

import * as vue from 'vue';
import * as vueClassSetup from 'vue-class-setup';

export { vue, vueClassSetup }

rspack.config.js

module.exports = {
  externalsType: 'module-import',
  externals: {
   vue: ['ssr-base/vue', 'vue'],
  'vue-class-setup': ['ssr-base/vue', 'vueClassSetup']
  }
};
@lzxb lzxb added feat New feature or request pending triage The issue/PR is currently untouched. labels Nov 4, 2024
@moonsky-all
Copy link

我遇到过一个相似的问题,直接定义一个vue别名解决了,不知道是不是你说的意思

// rsbuild.config.js
export default defineConfig({
  // ..
  source: {
    alias: {
      '@': resolve('src'),
      'vue': resolve('node_modules/vue/dist/vue.runtime.esm-bundler.js'),
    },
  },
  // ..
});

@lzxb
Copy link
Contributor Author

lzxb commented Nov 4, 2024

Thank you for your reply. You were referring to an alias, but I was referring to external expansion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request pending triage The issue/PR is currently untouched.
Projects
None yet
Development

No branches or pull requests

2 participants