diff --git a/__fixtures__/simple-project/.esbuild-jestrc.js b/__fixtures__/simple-project/.esbuild-jestrc.js index fee9738..072d16e 100644 --- a/__fixtures__/simple-project/.esbuild-jestrc.js +++ b/__fixtures__/simple-project/.esbuild-jestrc.js @@ -6,7 +6,7 @@ module.exports = { "outExtension": { ".js": ".mjs" }, - "external": ["chalk", "jest-allure2-reporter"], + "external": ["chalk", "dtrace-provider"], }, "preTransform": (path, contents) => { if (path.includes('lodash/noop')) { diff --git a/__fixtures__/simple-project/jest.config.js b/__fixtures__/simple-project/jest.config.js index 50f6f55..88a43ae 100644 --- a/__fixtures__/simple-project/jest.config.js +++ b/__fixtures__/simple-project/jest.config.js @@ -5,11 +5,10 @@ module.exports = { setupFilesAfterEnv: ['lodash/noop'], reporters: [ 'default', - 'jest-allure2-reporter', '/customReporter.js', ], testMatch: [ '/src/**/*.test.js', ], - testEnvironment: 'jest-allure2-reporter/environment-node', + testEnvironment: 'jest-environment-emit/node', }; diff --git a/__fixtures__/simple-project/package.json b/__fixtures__/simple-project/package.json index e9e329f..4e0ec04 100644 --- a/__fixtures__/simple-project/package.json +++ b/__fixtures__/simple-project/package.json @@ -11,6 +11,7 @@ "esbuild": "^0.19.8", "esbuild-jest-cli": "../..", "jest": "^29.5.0", + "jest-environment-emit": "^1.0.3", "jest-allure2-reporter": "^2.0.0-beta.1", "lodash": "^4.17.21" } diff --git a/index.mjs b/index.mjs index 5fb23f8..20f3b6b 100644 --- a/index.mjs +++ b/index.mjs @@ -72,6 +72,7 @@ export async function build(esbuildJestConfig = {}) { bundle: true, splitting: true, metafile: true, + external: externalModules, outbase: rootDir, banner: { js: ESM_REQUIRE_SHIM, @@ -88,7 +89,6 @@ export async function build(esbuildJestConfig = {}) { package: wrapPackageMiddleware(esbuildJestConfig.package), preTransform: esbuildJestConfig.preTransform, postTransform: esbuildJestConfig.postTransform, - ...(esbuildBaseConfig.external || []), }), ...(esbuildBaseConfig.plugins || []), ], diff --git a/plugin.mjs b/plugin.mjs index a785925..2853ec0 100644 --- a/plugin.mjs +++ b/plugin.mjs @@ -1,4 +1,4 @@ -import { lstat, readdir, readFile, rm, writeFile } from 'node:fs/promises'; +import { readFile, writeFile } from 'node:fs/promises'; import { sep, join, resolve } from 'node:path'; import importFrom from 'import-from'; import { convertPathToImport } from "./utils/resolve-module.mjs"; @@ -6,6 +6,7 @@ import { isBuiltinReporter } from "./utils/is-builtin-reporter.mjs"; import { mapSourceToOutputFiles } from "./utils/map-inputs-outputs.mjs"; import { moveJsFile } from "./utils/move-js-file.mjs"; import { pruneDirectory } from "./utils/prune-directory.mjs"; +import { JEST_DEPENDENCIES } from "./utils/jest-dependencies.mjs"; const passThrough = (filePath, fileContents) => fileContents; @@ -127,10 +128,16 @@ export default ({ }); build.onEnd(async (result) => { - const externalDependencies = Object.fromEntries(['jest', ...external].map(dep => { - const packageJson = importFrom.silent(rootDir, dep + '/package.json'); - return packageJson ? [dep, packageJson.version] : null; - }).filter(Boolean)); + const externalDependencies = Object.fromEntries( + ['jest', ...external] + .map(dep => { + if (JEST_DEPENDENCIES.includes(dep)) { + return null; + } + + const packageJson = importFrom.silent(rootDir, dep + '/package.json'); + return packageJson ? [dep, packageJson.version] : null; + }).filter(Boolean)); await writeFile(join(outdir, 'package.json'), JSON.stringify(packageMiddleware({ name: 'bundled-tests', diff --git a/utils/jest-dependencies.mjs b/utils/jest-dependencies.mjs index 0eb3809..4bd004d 100644 --- a/utils/jest-dependencies.mjs +++ b/utils/jest-dependencies.mjs @@ -1,5 +1,4 @@ export const JEST_DEPENDENCIES = [ - 'jest', 'jest-changed-files', 'jest-circus', 'jest-cli',