Created
January 25, 2024 20:04
-
-
Save AviranAbady/14779b147430e62fb54c95f9119acbe8 to your computer and use it in GitHub Desktop.
esbuild bull plugin to resolve "No .lua files found! " error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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