Skip to content

The plugin's onload disables watch. #24270

@kiki-kanri

Description

@kiki-kanri

What version of Bun is running?

1.3.1+89fa0f343

What platform is your computer?

Linux 6.8.12-16-pve x86_64 unknown

What steps can reproduce the bug?

When using a plugin that utilizes onLoad, it will render all subsequent await import watches ineffective, preventing them from restarting upon changes.

  1. Create index.ts
import { plugin as registerPlugin } from 'bun';

console.log('index', Date.now());

// Register plugin
registerPlugin({
    name: 'plugin',
    setup(builder) {
        builder.onLoad(
            { filter: /.*/ },
            async ({ path }) => {
                return {
                    contents: await Bun.file(path).text(),
                    loader: 'ts',
                };
            },
        );
    },
});

await import('./a');
  1. Create a.ts
console.warn('file a', Date.now());
  1. run watch mode
bun --watch run ./index.ts

Now save a.ts file, nothing happened.

What is the expected behavior?

Any changes to files imported via import should trigger an automatic restart.

What do you see instead?

No automatic restart.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions