Skip to content

fix(node): should call hooks with await#950

Merged
hyf0 merged 1 commit intorolldown:mainfrom
zscumt123:fix_js_hooks
Apr 23, 2024
Merged

fix(node): should call hooks with await#950
hyf0 merged 1 commit intorolldown:mainfrom
zscumt123:fix_js_hooks

Conversation

@zscumt123
Copy link
Copy Markdown
Contributor

Description

When building with Rolldown, add two buildStart hook,The plugin execution result is incorrect

import { defineConfig } from 'rolldown'

async function sleep(duration) {
  return new Promise((resolve) => {
    setTimeout(() => {
      //here console  sleep
      console.log('sleep')
      resolve(duration)
    }, duration)
  })
}

export default defineConfig({
  input: './index.js',
  resolve: {
    conditionNames: ['import'],
  },
  plugins: [
    {
      name: 'build_start1',
      async buildStart(options) {
        console.log('1')
      //  here sleep 4000ms
        await sleep(4000)
      },
    },
    {
      name: 'build_start2',
      async buildStart(options) {
        console.log(2)
      },
    },
  ],
})

the result , console.log(sleep) execute after build end
image

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 22, 2024

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit cf8cf72
🔍 Latest deploy log https://app.netlify.com/sites/rolldown-rs/deploys/66273c0a21b2b50008ecc856

Copy link
Copy Markdown
Member

@hyf0 hyf0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching it!

@hyf0
Copy link
Copy Markdown
Member

hyf0 commented Apr 22, 2024

Ci failed.

@zscumt123
Copy link
Copy Markdown
Contributor Author

image I don't know how to resolve it , can you help me?

@hyf0 hyf0 enabled auto-merge April 23, 2024 04:41
@hyf0 hyf0 disabled auto-merge April 23, 2024 04:42
@hyf0 hyf0 changed the title fix: add await when call some hooks in js fix(node): should call hooks with await Apr 23, 2024
@hyf0 hyf0 self-assigned this Apr 23, 2024
@hyf0 hyf0 added this pull request to the merge queue Apr 23, 2024
Merged via the queue into rolldown:main with commit 1c5c7d5 Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants