MariusVatasoiu
MariusVatasoiu9mo ago

esbuild-deno-loader with npm private registry

Did anyone used the esbuild-deno-loader with npm: specifier while using a private npm registry that requires authentication? Does Deno use the npmrc in any way? I saw the option to set a custom registry, but what about the credentials? I'm getting the "Module not found" error and not sure why. I have the feeling it's a network issue, but the error is too vague.
6 Replies
marvinh.
marvinh.9mo ago
npm stores auth tokens in .npmrc in the users home dir afaik. Could be that the esbuild deno loader isn't respecting that
MariusVatasoiu
MariusVatasoiuOP9mo ago
Is this something that the loader should do or the runtime itself?
marvinh.
marvinh.9mo ago
I'm not familiar enough with the internals of esbuild loader to guess if the problem is there or in deno
MariusVatasoiu
MariusVatasoiuOP9mo ago
I'm using Luca's plugin: https://github.com/lucacasonato/esbuild_deno_loader But from the source code I don't see anything related with the npmrc file
GitHub
GitHub - lucacasonato/esbuild_deno_loader: Deno module resolution f...
Deno module resolution for esbuild. Contribute to lucacasonato/esbuild_deno_loader development by creating an account on GitHub.
MariusVatasoiu
MariusVatasoiuOP9mo ago
And, since the npm: specifier is built in the runtime, I'm expecting to be some config related with the runtime my deno.json looks somthing like this:
{
"imports": {
"lit": "npm:lit@^2.0.0"
}
}
{
"imports": {
"lit": "npm:lit@^2.0.0"
}
}
// buil.ts
import * as esbuild from 'npm:esbuild@0.20.2';
// Import the WASM build on platforms where running subprocesses is not
// permitted, such as Deno Deploy, or when running without `--allow-run`.
// import * as esbuild from "https://deno.land/x/esbuild@0.20.2/wasm.js";

import { denoPlugins } from 'jsr:@luca/esbuild-deno-loader@^0.10.3';

const result = await esbuild.build({
plugins: [...denoPlugins()],
entryPoints: ['./static/index.js'],
outfile: './dist/static.esm.js',
bundle: true,
format: 'esm'
});

console.log(result.outputFiles);

esbuild.stop();
// buil.ts
import * as esbuild from 'npm:esbuild@0.20.2';
// Import the WASM build on platforms where running subprocesses is not
// permitted, such as Deno Deploy, or when running without `--allow-run`.
// import * as esbuild from "https://deno.land/x/esbuild@0.20.2/wasm.js";

import { denoPlugins } from 'jsr:@luca/esbuild-deno-loader@^0.10.3';

const result = await esbuild.build({
plugins: [...denoPlugins()],
entryPoints: ['./static/index.js'],
outfile: './dist/static.esm.js',
bundle: true,
format: 'esm'
});

console.log(result.outputFiles);

esbuild.stop();
MariusVatasoiu
MariusVatasoiuOP9mo ago
My problem might be related with https://github.com/denoland/deno/issues/19900 I think I can't use a private npm registry that requires auth.
GitHub
DENO_AUTH_TOKENS does not authenticate against npm.pkg.github.com ·...
Hi, I'm doing a POC to see if our company can start replacing node with deno. I have a private npm package in npm.pkg.github.com that I'm trying to import. I'm trying to run a single-li...