Closed kasbah closed 1 year ago
Also getting this issue as well with graphql-tools
✘ [ERROR] No matching export in "browser-external:path" for import "join"
node_modules/@graphql-tools/load-files/index.mjs:3:9:
3 │ import { join, extname } from 'path';
╵ ~~~~
✘ [ERROR] No matching export in "browser-external:path" for import "extname"
node_modules/@graphql-tools/load-files/index.mjs:3:15:
3 │ import { join, extname } from 'path';
╵ ~~~~~~~
✘ [ERROR] No matching export in "browser-external:fs" for import "readFileSync"
node_modules/@graphql-tools/load-files/index.mjs:4:9:
4 │ import { readFileSync, promises, statSync } from 'fs';
╵ ~~~~~~~~~~~~
✘ [ERROR] No matching export in "browser-external:fs" for import "promises"
node_modules/@graphql-tools/load-files/index.mjs:4:23:
4 │ import { readFileSync, promises, statSync } from 'fs';
╵ ~~~~~~~~
✘ [ERROR] No matching export in "browser-external:fs" for import "statSync"
node_modules/@graphql-tools/load-files/index.mjs:4:33:
4 │ import { readFileSync, promises, statSync } from 'fs';
╵ ~~~~~~~~
✘ [ERROR] No matching export in "browser-external:module" for import "createRequire"
node_modules/@graphql-tools/load-files/index.mjs:6:9:
6 │ import { createRequire } from 'module';
╵ ~~~~~~~~~~~~~
✘ [ERROR] No matching export in "browser-external:process" for import "cwd"
node_modules/@graphql-tools/load-files/index.mjs:7:9:
7 │ import { cwd } from 'process';
As stated in the docs you need to put these into defineConfig
optimizeDeps: {
// Vite does not work well with optionnal dependencies,
// you can mark them as ignored for now
// eg: for nestjs, exlude these optional dependencies:
exclude: [
"child_process",
"util",
"crypto",
"etc etc",
"url",
"events",
],
},
Thanks @romanzy-1612 I can confirm this fixes it! I would have never guessed this since I would never think of the internal node dependencies as "optional".
Since this plugin is focused on node I move to update the example vite.config.js in the readme with common node internal dependencies in optimizeDeps {exclude: [...]}
at the very least.
Even better would be if this plugin could modify the optimizeDeps
automatically, is that a possibility?
with latest vite 4 and latest version of this plugin, you don't need to do the exclude hack anymore for node app.
Repro: https://github.com/kasbah/vite-plugin-node-example
When I run:
I get