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

Error when building a project with Vite #12

Closed
mthh opened this issue Jan 22, 2024 · 2 comments
Closed

Error when building a project with Vite #12

mthh opened this issue Jan 22, 2024 · 2 comments

Comments

@mthh
Copy link

mthh commented Jan 22, 2024

Hi and thanks for your work on this library !

Since version 11.0.0 (i.e. with versions 11.0.0 and 12.0.0) I have encountered problems when I compile a project with Vite (5.0.x) that uses "main-thread-scheduling".

The compilation fails with the following message and Vite stops :

 [ERROR] Could not resolve "./src/utils/queueTask"

    node_modules/main-thread-scheduling/index.js:7:37:
      7  export { default as queueTask } from './src/utils/queueTask';
                                              ~~~~~~~~~~~~~~~~~~~~~~~

 [ERROR] Could not resolve "./src/utils/withResolvers"

    node_modules/main-thread-scheduling/index.js:8:41:
      8  export { default as withResolvers } from './src/utils/withResolvers';
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~

 [ERROR] Could not resolve "./src/utils/requestAfterFrame"

    node_modules/main-thread-scheduling/index.js:9:38:
      9  export { default as afterFrame } from './src/utils/requestAfterFrame';
                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 [ERROR] Could not resolve "./utils/hasValidContext"

    node_modules/main-thread-scheduling/src/isTimeToYield.js:2:28:
      2  import hasValidContext from './utils/hasValidContext';
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~

 [ERROR] Could not resolve "./utils/queueTask"

    node_modules/main-thread-scheduling/src/yieldControl.js:2:22:
      2  import queueTask from './utils/queueTask';
                               ~~~~~~~~~~~~~~~~~~~

 [ERROR] Could not resolve "./utils/hasValidContext"

    node_modules/main-thread-scheduling/src/yieldControl.js:4:28:
      4  import hasValidContext from './utils/hasValidContext';
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~

 [ERROR] Could not resolve "./utils/promiseEscape"

    node_modules/main-thread-scheduling/src/yieldControl.js:5:58:
      5  ...PromiseEscape, requestPromiseEscape } from './utils/promiseEscape';
                                                       ~~~~~~~~~~~~~~~~~~~~~~~

 [ERROR] Could not resolve "./tasks/createTask"

    node_modules/main-thread-scheduling/src/yieldControl.js:6:23:
      6  import createTask from './tasks/createTask';
                                ~~~~~~~~~~~~~~~~~~~~

 [ERROR] Could not resolve "./tasks/removeTask"

    node_modules/main-thread-scheduling/src/yieldControl.js:7:23:
      7  import removeTask from './tasks/removeTask';
                                ~~~~~~~~~~~~~~~~~~~~

 [ERROR] Could not resolve "./tasks/nextTask"

    node_modules/main-thread-scheduling/src/yieldControl.js:8:25:
      8  import { nextTask } from './tasks/nextTask';
                                  ~~~~~~~~~~~~~~~~~~

 [ERROR] Could not resolve "./utils/withResolvers"

    node_modules/main-thread-scheduling/src/schedulingState.js:1:26:
      1  import withResolvers from './utils/withResolvers';
                                   ~~~~~~~~~~~~~~~~~~~~~~~

Error: Build failed with 11 errors:
node_modules/main-thread-scheduling/index.js:7:37: ERROR: Could not resolve "./src/utils/queueTask"
node_modules/main-thread-scheduling/index.js:8:41: ERROR: Could not resolve "./src/utils/withResolvers"
node_modules/main-thread-scheduling/index.js:9:38: ERROR: Could not resolve "./src/utils/requestAfterFrame"
node_modules/main-thread-scheduling/src/isTimeToYield.js:2:28: ERROR: Could not resolve "./utils/hasValidContext"
node_modules/main-thread-scheduling/src/schedulingState.js:1:26: ERROR: Could not resolve "./utils/withResolvers"
...
    at failureErrorWithLog (/home/projects/vitejs-vite-adh7q9/node_modules/esbuild/lib/main.js:1641:15)
    at eval (/home/projects/vitejs-vite-adh7q9/node_modules/esbuild/lib/main.js:1049:25)
    at eval (/home/projects/vitejs-vite-adh7q9/node_modules/esbuild/lib/main.js:1517:9) {
  errors: [Getter/Setter],
  warnings: [Getter/Setter]
}

It happens in a large project I'm working on but you can see a minimal repro here in a projet with only Vite, Typescript and main-thread-scheduling (this is a stackblitz project, hope this is fine to demonstrate the issue - try to change the main-thread-scheduling version to 10.0.0 in package.json to see it was working fine with older versions).

Am I doing something wrong or is there a workaround ?
Thanks !

@astoilkov
Copy link
Owner

This is now fixed and released. Sorry for the inconvenience and thanks for reporting!

@mthh
Copy link
Author

mthh commented Jan 22, 2024

Thanks for the quick fix and the new release!

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

No branches or pull requests

2 participants