Skip to content

Instantly share code, notes, and snippets.

@AviranAbady
Created January 25, 2024 20:04
Show Gist options
  • Save AviranAbady/14779b147430e62fb54c95f9119acbe8 to your computer and use it in GitHub Desktop.
Save AviranAbady/14779b147430e62fb54c95f9119acbe8 to your computer and use it in GitHub Desktop.
esbuild bull plugin to resolve "No .lua files found! " error
// No .lua files found! - Error solution
import * as esbuild from 'esbuild'
import fs from 'fs';
import path from 'path';
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
let bullPlugin = {
name: 'replace-bull-string',
setup(build) {
build.onLoad({ filter: /node_modules\/bull\/lib\/commands\/index\.js$/ }, (args) => {
let contents = fs.readFileSync(args.path, 'utf8');
contents = contents.replace(/__dirname/g, `"${path.dirname(require.resolve("bull"))}/lib/commands"`);
return { contents, loader: 'default' };
});
}
};
// esbuild server/main.js --bundle --platform=node --target=node18 --outdir=dist --tree-shaking=true;",
await esbuild.build({
entryPoints: ['server/main.js'],
bundle: true,
outdir: 'dist',
platform: 'node',
target: 'node18',
treeShaking: true,
plugins: [bullPlugin]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment