Closed jordandobrev closed 10 months ago
I'm also seeing this behavior!
thrown from this line: https://github.com/lucacasonato/esbuild_deno_loader/blob/main/src/loader_native.ts#L161
import { build } from "npm:esbuild";
import { solidPlugin } from "npm:esbuild-plugin-solid";
import { denoPlugins } from "https://deno.land/x/esbuild_deno_loader@0.8.1/mod.ts";
import { resolve } from 'https://deno.land/std@0.198.0/path/mod.ts';
const importMapURL = new URL('file://' + resolve('./import_map.json'))
const [denoResolver, denoLoader] = [...denoPlugins({ importMapURL })];
const result = await build({
entryPoints: ["./source/index.tsx"],
outfile: "./public/index.js",
bundle: true,
format: "esm",
treeShaking: true,
minify: true,
plugins: [
denoResolver,
solidPlugin({ solid: { moduleName: 'npm:solid-js/web' } }),
denoLoader
],
});
import { render } from "solid-js/web"
import { Motion } from "npm:@motionone/solid";
function App() {
return <Motion>Hello world</Motion>
}
render(() => <App />, document.body)
...
✘ [ERROR] NPM package not found. [plugin deno-loader]
../../../../../../.deno/deno_esbuild/@solid-primitives/refs@1.0.5_solid-js@1.7.11/node_modules/@solid-primitives/refs/dist/index.js:1:35:
1 │ import { chain, arrayEquals } from '@solid-primitives/utils';
...
error: Uncaught Error: Build failed with 17 errors:
...
FYI @jordandobrev it looks like this only happens with the deno global cache node_modules? As a workaround, I'm finding that this error seems to go away if using the nodeModulesDir: true
. Not 100% if this is meant to be a public api or not, since it's not mentioned on the README, and it creates a node_modules dir in your project, but does seem to work. Probably portable
works as well?
But for your example, this might work:
const result = await esbuild.build({
plugins: [...denoPlugins({ nodeModulesDir: true })],
entryPoints: [`${source}/handler.ts`],
outfile: `${dist_folder}/handler-bundle.js`,
bundle: true,
format: "esm",
});
@bpevs I just tried that fix with nodeModulesDir: true
and seems to have helped my most recent issue
Note that nodeModulesDir: true
will not work on Deno Deploy https://github.com/lucacasonato/esbuild_deno_loader#limitations
This should be fixed by #104
fix works for me on v0.8.4! Thanks!
Hey :wave:
Tried bundling one of my aws lambda projects and I'm getting errors when trying to do it:
my deps.ts
my bundle.ts
This resunts in over 30+ errors:
Any ideas how I can sort this out?