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]: The dynamic import dependency module has been elevated to the entrance #8736

Open
lzxb opened this issue Dec 17, 2024 · 8 comments
Open
Labels
bug Something isn't working pending triage The issue/PR is currently untouched.

Comments

@lzxb
Copy link
Contributor

lzxb commented Dec 17, 2024

System Info

System:
OS: macOS 15.1.1
CPU: (8) arm64 Apple M1
Memory: 90.00 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.11.0 - ~/.nvm/versions/node/v22.11.0/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v22.11.0/bin/yarn
npm: 10.9.0 - ~/.nvm/versions/node/v22.11.0/bin/npm
pnpm: 9.15.0 - ~/.nvm/versions/node/v22.11.0/bin/pnpm
bun: 1.1.27 - ~/.bun/bin/bun
Browsers:
Safari: 18.1.1
npmPackages:
@rspack/cli: 1.1.6 => 1.1.6
@rspack/core: 1.1.6 => 1.1.6

  • [ ]

Details

rspack.config.js

export default {
    entry: './src/index.js',
    experiments: {
        outputModule: true
    },
    output: {
        chunkFormat: 'module',
        chunkLoading: 'import',
        module: true
    },
    externalsType: 'module-import',
    externals: ['vue', 'axios'],
    optimization: {
        minimize: false
    }
};

src/index.js

console.log('>>>>>>>>>>>>> start');
function start () {
    import('./app.js');
}
console.log('>>>>>>>>>>>>> end');
import('axios');

src/app.js

import { version } from 'vue';

console.log(version);
Image

Reproduce link

https://github.com/lzxb/rspack-dynamic-import-to-top

Reproduce Steps

pnpm i
pnpm build

@lzxb lzxb added bug Something isn't working pending triage The issue/PR is currently untouched. labels Dec 17, 2024
@fi3ework
Copy link
Member

As a temp workaround, you could explicitly declare the external type of the dynamic imported request to import xx, e.g.

externals: { vue: 'import vue', axios: 'axios' },

I'll take a look into the source code.

@fi3ework fi3ework marked this as a duplicate of web-infra-dev/rslib#572 Dec 19, 2024
@lzxb
Copy link
Contributor Author

lzxb commented Dec 19, 2024

The import type will lose all exports

@fi3ework
Copy link
Member

The import type will lose all exports

What does it mean.

@lzxb
Copy link
Contributor Author

lzxb commented Dec 19, 2024

Compile into library mode, use import type, all exports will be deleted

@fi3ework
Copy link
Member

Could you update the reproduction demo.

@lzxb
Copy link
Contributor Author

lzxb commented Dec 19, 2024

Is it adding an import type demo?

@fi3ework
Copy link
Member

Compile into library mode, use import type, all exports will be deleted

To explain what does this mean is enough.

@lzxb
Copy link
Contributor Author

lzxb commented Dec 19, 2024

I updated. in feat-import branch.

Image

no have export

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending triage The issue/PR is currently untouched.
Projects
None yet
Development

No branches or pull requests

2 participants