Giter VIP home page Giter VIP logo

Comments (5)

Septh avatar Septh commented on June 21, 2024 3

Hi! rollup-plugin-node-externals author here.

I was not aware of this and the linked discussion until @chandu filed Septh/rollup-plugin-node-externals#30 which I fixed by not relying on buildStart to initialize my variables. Simple enough.

However I do believe that this is a bug that should be fixed in Vitest because the order in which the hooks are called is clearly defined by Rollup's documentation and diverging from that order is wrong (and my plugin might not be the only one affected).

from vitest.

hi-ogawa avatar hi-ogawa commented on June 21, 2024

It looks like buildStart is still called, but the issue is that resolveId is called before buildStart when you have enforce: "pre".
I also made a repro here:
https://github.com/hi-ogawa/reproductions/tree/main/vitest-5616-plugin-build-start

> vitest

@resolveId(pre) { source: 'vitest' }
@resolveId(pre) { source: 'vitest' }
@buildStart(pre)
@buildStart(normal)

 DEV  v1.5.1 /home/projects/wmaivylmj.github
...

I remembered someone mentioned that buildStart is not working, but it looks like the same issue where resolveId being getting called first:

from vitest.

hi-ogawa avatar hi-ogawa commented on June 21, 2024

This resolveId seems to be the trigger, which is called during configureServer and before buildStart

const projectVitestPath = await this.vitenode.resolveId('vitest')

Quick logging from plugin shows something like this:

@configureServer(pre)
@resolveId(pre) { source: 'vitest' }
@resolveId(pre) { source: 'vitest' }
@configureServer(normal)
@buildStart(pre)
@buildStart(normal)

@sagargurtu Can you explain what is your use case? The linked discussion mentioned rollup-plugin-node-externals. I think this is technically what Vitest shouldn't do, but I'm not sure if there is a quick way around.
Depending on the use case, there might be a workaround on plugin side.

from vitest.

sagargurtu avatar sagargurtu commented on June 21, 2024

@hi-ogawa While I could potentially move my initialization code to config() or the function that returns the plugin object, I agree with @Septh as many other existing plugins could break because of this issue.

from vitest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.