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

Using babylonjs/loaders, the error "config must export or return an object" occurs #4482

Open
4 tasks done
Codfisher opened this issue Jan 10, 2025 · 1 comment
Open
4 tasks done
Labels
build Related to the build system needs more discussion

Comments

@Codfisher
Copy link

Codfisher commented Jan 10, 2025

Describe the bug

Using @babylonjs/loaders will cause an error during the build phase: KHR_animation_pointer.data.js: config must export or return an object.

Reproduction

https://stackblitz.com/edit/vite-v1c8np4w

Run npm run docs:build.

Expected behavior

The error "config must export or return an object" should not occur.

Removing import '@babylonjs/loaders' will prevent any errors from occurring.

I suspect it might be due to the filename KHR_animation_pointer.data.js, which might cause VitePress to mistakenly identify it as a data loader, leading to this error.

If my guess is correct, might there be a need for a way to exclude specific files?

System Info

@babylonjs/loaders: 7.43.0
vitepress: 1.5.0

Additional context

vitepress build docs

vitepress v1.5.0

⠇ building client + server bundles...failed to load config from /home/projects/vite-v1c8np4w/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_animation_pointer.data.js
x Build failed in 3.63s
✖ building client + server bundles...
build error:
[commonjs--resolver] Could not load /home/projects/vite-v1c8np4w/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_animation_pointer.data.js: config must export or return an object.
[commonjs--resolver] Could not load /home/projects/vite-v1c8np4w/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_animation_pointer.data.js: config must export or return an object.
at Module.loadConfigFromFile (file:///home/projects/vite-v1c8np4w/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:66589:13)
at async Object.load (file:///home/projects/vite-v1c8np4w/node_modules/vitepress/dist/node/chunk-DMuPggCS.js:44533:21)

image

Validations

@Codfisher Codfisher added the bug: pending triage Maybe a bug, waiting for confirmation label Jan 10, 2025
@brc-dd
Copy link
Member

brc-dd commented Jan 10, 2025

There isn't any good way except to completely disable the plugin:

import { defineConfig } from 'vitepress';

export default defineConfig({
  vite: {
    plugins: [
      {
        name: 'disable-vp-static-data-plugin',
        configResolved(config) {
          // @ts-ignore
          config.plugins.splice(
            config.plugins.findIndex((p) => p.name === 'vitepress:data'),
            1
          );
        },
      },
    ],
  },
});

Maybe we can add some configuration in the data loader plugin to support excluding things.

@brc-dd brc-dd added build Related to the build system needs more discussion and removed bug: pending triage Maybe a bug, waiting for confirmation labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Related to the build system needs more discussion
Projects
None yet
Development

No branches or pull requests

2 participants