Merge pull request #11671 from Budibase/fix/jest_relative_mocks
Fix Jest relative mocks from @budibase/backend-core
This commit is contained in:
commit
46e4532878
|
@ -6,7 +6,7 @@
|
|||
"types": "dist/src/index.d.ts",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
"./tests": "./dist/tests.js",
|
||||
"./tests": "./dist/tests/index.js",
|
||||
"./*": "./dist/*.js"
|
||||
},
|
||||
"author": "Budibase",
|
||||
|
|
|
@ -1,6 +1,21 @@
|
|||
#!/usr/bin/node
|
||||
|
||||
const coreBuild = require("../../../scripts/build")
|
||||
|
||||
coreBuild("./src/plugin/index.ts", "./dist/plugins.js")
|
||||
coreBuild("./src/index.ts", "./dist/index.js")
|
||||
coreBuild("./tests/index.ts", "./dist/tests.js")
|
||||
|
||||
const glob = require("glob")
|
||||
const inputFiles = [
|
||||
...glob.sync("./src/**/*.[tj]s", { nodir: true }),
|
||||
...glob.sync("./tests/**/*.[tj]s", { nodir: true }),
|
||||
]
|
||||
|
||||
const path = require("path")
|
||||
for (const file of inputFiles) {
|
||||
coreBuild(file, `./${path.join("dist", file.replace(/\.ts$/, ".js"))}`, {
|
||||
skipMeta: true,
|
||||
bundle: false,
|
||||
forcedFormat: "cjs",
|
||||
})
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ const { nodeExternalsPlugin } = require("esbuild-node-externals")
|
|||
|
||||
var argv = require("minimist")(process.argv.slice(2))
|
||||
|
||||
function runBuild(entry, outfile) {
|
||||
function runBuild(entry, outfile, opts = { skipMeta: false, bundle: true }) {
|
||||
const isDev = process.env.NODE_ENV !== "production"
|
||||
const tsconfig = argv["p"] || `tsconfig.build.json`
|
||||
const tsconfigPathPluginContent = JSON.parse(
|
||||
|
@ -36,12 +36,16 @@ function runBuild(entry, outfile) {
|
|||
]
|
||||
}
|
||||
|
||||
const metafile = !opts.skipMeta
|
||||
const { bundle } = opts
|
||||
|
||||
const sharedConfig = {
|
||||
entryPoints: [entry],
|
||||
bundle: true,
|
||||
bundle,
|
||||
minify: !isDev,
|
||||
sourcemap: isDev,
|
||||
tsconfig,
|
||||
format: opts?.forcedFormat,
|
||||
plugins: [
|
||||
TsconfigPathsPlugin({ tsconfig: tsconfigPathPluginContent }),
|
||||
nodeExternalsPlugin(),
|
||||
|
@ -50,15 +54,10 @@ function runBuild(entry, outfile) {
|
|||
loader: {
|
||||
".svelte": "copy",
|
||||
},
|
||||
metafile: true,
|
||||
external: [
|
||||
"deasync",
|
||||
"mock-aws-s3",
|
||||
"nock",
|
||||
"pino",
|
||||
"koa-pino-logger",
|
||||
"bull",
|
||||
],
|
||||
metafile,
|
||||
external: bundle
|
||||
? ["deasync", "mock-aws-s3", "nock", "pino", "koa-pino-logger", "bull"]
|
||||
: undefined,
|
||||
}
|
||||
|
||||
build({
|
||||
|
@ -77,10 +76,12 @@ function runBuild(entry, outfile) {
|
|||
)
|
||||
})
|
||||
|
||||
if (metafile) {
|
||||
fs.writeFileSync(
|
||||
`dist/${path.basename(outfile)}.meta.json`,
|
||||
JSON.stringify(result.metafile)
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue