duckdb / duckdb-node

MIT License
54 stars 26 forks source link

Compatibility with nextjs/shadcn projects #133

Open adsharma opened 2 hours ago

adsharma commented 2 hours ago

This repo works just fine when nextjs/shadcn are not involved.

Repro:

 git clone https://github.com/sachidumaleesha/shadcn-dashboard test
 cd test
 npm install duckdb-async

Hit an API with some test code and you get:

⨯ ./node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <!doctype html>
| <html>
| <head>

Import trace for requested module:
./node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html
./node_modules/@mapbox/node-pre-gyp/lib/ sync ^\.\/.*$
./node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js
./node_modules/duckdb/lib/duckdb-binding.js
./node_modules/duckdb/lib/duckdb.js
./node_modules/duckdb-async/dist/duckdb-async.js

Any hint on what's going on here and how to fix it?

adsharma commented 2 hours ago

This solution worked for me:

$ cat next.config.js
export default {
  webpack: (config) => {
    config.externals.push('duckdb');
    return config;
  }
};

But for projects using turbopack, there are still some webloader related failures.