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]: alias configuration does not take effect #553

Closed
Lisheri opened this issue Dec 13, 2024 · 4 comments · Fixed by #535
Closed

[Bug]: alias configuration does not take effect #553

Lisheri opened this issue Dec 13, 2024 · 4 comments · Fixed by #535
Labels
🐞 bug Something isn't working

Comments

@Lisheri
Copy link

Lisheri commented Dec 13, 2024

Version

System: macos14.3.1
npmPackages: pnpm
Rslib 0.1.12

Details

rslib.config.ts

import { defineConfig } from '@rslib/core';
import { pluginVue } from '@rsbuild/plugin-vue';
import { pluginVueJsx } from '@rsbuild/plugin-vue-jsx';
import { pluginBabel } from '@rsbuild/plugin-babel';

export default defineConfig({
  resolve: {
    alias: {
      '@': './src'
    }
  },
  source: {
    entry: {
      index: ['./src/**']
    }
  },
  lib: [
    {
      bundle: false,
      dts: true,
      format: 'esm'
    }
  ],
  output: {
    target: 'web'
  },
  plugins: [
    pluginBabel({
      include: /\.(?:jsx|tsx)$/
    }),
    pluginVue(),
    pluginVueJsx()
  ],
  tools: {
    rspack: {
      plugins: [
        require('unplugin-vue-macros/rspack')({
          // 覆盖插件选项
          vue: pluginVue(),
          vueJsx: pluginVueJsx()
        })
      ]
    }
  }
});

tsconfig.json

{
  "compilerOptions": {
    "lib": ["DOM", "ES2021"],
    "module": "ESNext",
    "jsx": "preserve",
    "jsxFactory": "h",
    "jsxFragmentFactory": "Fragment",
    "strict": true,
    "skipLibCheck": true,
    "isolatedModules": true,
    "resolveJsonModule": true,
    "moduleResolution": "bundler",
    "useDefineForClassFields": true,
    "target": "esnext",
    "baseUrl": ".",
    "noImplicitAny": false,
    "types": ["unplugin-vue-macros/macros-global"],
    "paths": {
      "@/*": [
        "./src/*"
      ]
    },
  },
  "vueCompilerOptions": {
    "plugins": ["unplugin-vue-macros/volar"],
  },
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
}

origincode
Image

after build
Image

after building, the path alias is not processed

Reproduce link

https://github.com/Lisheri/rslib_vue_components

Reproduce Steps

pnpm i
pnpm build
see dist/index.js

@Lisheri Lisheri added the 🐞 bug Something isn't working label Dec 13, 2024
@Timeless0911
Copy link
Contributor

Timeless0911 commented Dec 13, 2024

In bundleless mode, it should be externals not alias issue, see https://lib.rsbuild.dev/config/rsbuild/resolve#resolvealias.

We will support processing path redirection in #535.

@Lisheri
Copy link
Author

Lisheri commented Dec 16, 2024

ok
But what I need is to process local path mapping, and do not need to deal with external dependency paths. When I enable bundle mode, the following error is directly triggered. Is it related to the above issue?

Image

Reproduce link unchanged

@Timeless0911
Copy link
Contributor

In bundle mode, you should set entry to ./src/index.tsx.

@chenjiahan
Copy link
Member

In bundle mode, you should set entry to ./src/index.tsx.

We can add a pre-check for this to provide better error diagnostics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants