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 Report]: sideEffect: true has no effect #1809

Open
shulandmimi opened this issue Oct 8, 2024 · 1 comment
Open

[Bug Report]: sideEffect: true has no effect #1809

shulandmimi opened this issue Oct 8, 2024 · 1 comment
Labels
v2.0 v2.0 version

Comments

@shulandmimi
Copy link
Member

Steps to reproduce

  1. code
// farm.config.ts
import { defineConfig } from '@farmfe/core';

export default defineConfig({
    compilation: {
        output: {
            targetEnv: 'library-node',
        },
        input: {
            index: './index.ts',
        },
        minify: false,
        mode: 'development',
        persistentCache: false,
    },
    plugins: [
        {
            name: 'sideEffect',
            resolve: {
                filters: {
                    sources: ['.+'],
                    importers: ['.+'],
                },
                executor(param, context, hookContext) {
                    console.log(param);
                    if (param.source === 'virtual:foo')
                        return {
                            sideEffects: true,
                            resolvedPath: 'virtual:foo',
                        };

                    return undefined;
                },
            },
            load: {
                filters: {
                    resolvedPaths: ['.+'],
                },
                executor(param, context, hookContext) {
                    if (param.resolvedPath === 'virtual:foo')
                        return {
                            content: 'export const name = 1',
                            moduleType: 'js',
                        };
                },
            },
        },
    ],
});
import 'virtual:foo';

console.log('foo');

Reproduce link

No response

What is actually happening?

When virtual:foo has sideEffect set to true it should be preserved

System Info

System:
    OS: Linux 6.10 Arch Linux
    CPU: (32) x64 Intel(R) Core(TM) i9-14900HX
    Memory: 10.45 GB / 31.07 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.3.0 - /run/user/1000/fnm_multishells/84882_1717558110082/bin/node
    Yarn: 1.22.22 - ~/.local/share/pnpm/yarn
    npm: 10.8.1 - /run/user/1000/fnm_multishells/84882_1717558110082/bin/npm
    pnpm: 9.6.0 - ~/.local/share/pnpm/pnpm
    bun: 1.1.16 - ~/.bun/bin/bun
  npmPackages:
    @farmfe/core: ^1.3.24 => 1.3.24
@shulandmimi shulandmimi added the bug Something isn't working label Oct 8, 2024
@wre232114 wre232114 added v2.0 v2.0 version and removed bug Something isn't working labels Oct 11, 2024
@wre232114
Copy link
Member

support disable tree shake for specified module in 2.0

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

No branches or pull requests

2 participants