-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Accept and await a promise in `sourcemaps.filesToDeleteAf…
…terUpload` (#677) Widen the accepted type for `filesToDeleteAfterSourcemaps` to allow us (as well as users) to pass in a `Promise<string | string[]>` to do so. This promise can resolve whenever we know what to set and we await the promise before calling `glob` to get all file paths to delete.
- Loading branch information
Showing
6 changed files
with
65 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
27 changes: 27 additions & 0 deletions
27
...es/integration-tests/fixtures/after-upload-deletion-promise/after-upload-deletion.test.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* eslint-disable jest/no-standalone-expect */ | ||
/* eslint-disable jest/expect-expect */ | ||
import path from "path"; | ||
import fs from "fs"; | ||
import { testIfNodeMajorVersionIsLessThan18 } from "../../utils/testIf"; | ||
|
||
describe("Deletes files with `filesToDeleteAfterUpload` set to a promise", () => { | ||
testIfNodeMajorVersionIsLessThan18("webpack 4 bundle", () => { | ||
expect(fs.existsSync(path.join(__dirname, "out", "webpack4", "bundle.js.map"))).toBe(false); | ||
}); | ||
|
||
test("webpack 5 bundle", () => { | ||
expect(fs.existsSync(path.join(__dirname, "out", "webpack5", "bundle.js.map"))).toBe(false); | ||
}); | ||
|
||
test("esbuild bundle", () => { | ||
expect(fs.existsSync(path.join(__dirname, "out", "esbuild", "bundle.js.map"))).toBe(false); | ||
}); | ||
|
||
test("rollup bundle", () => { | ||
expect(fs.existsSync(path.join(__dirname, "out", "rollup", "bundle.js.map"))).toBe(false); | ||
}); | ||
|
||
test("vite bundle", () => { | ||
expect(fs.existsSync(path.join(__dirname, "out", "vite", "bundle.js.map"))).toBe(false); | ||
}); | ||
}); |
2 changes: 2 additions & 0 deletions
2
packages/integration-tests/fixtures/after-upload-deletion-promise/input/bundle.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// eslint-disable-next-line no-console | ||
console.log("whatever"); |
25 changes: 25 additions & 0 deletions
25
packages/integration-tests/fixtures/after-upload-deletion-promise/setup.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import * as path from "path"; | ||
import { createCjsBundles } from "../../utils/create-cjs-bundles"; | ||
|
||
const outputDir = path.resolve(__dirname, "out"); | ||
|
||
["webpack4", "webpack5", "esbuild", "rollup", "vite"].forEach((bundler) => { | ||
const fileDeletionGlobPromise = new Promise<string[]>((resolve) => { | ||
setTimeout(() => { | ||
resolve([path.join(__dirname, "out", bundler, "bundle.js.map")]); | ||
}, 1000); | ||
}); | ||
|
||
createCjsBundles( | ||
{ | ||
bundle: path.resolve(__dirname, "input", "bundle.js"), | ||
}, | ||
outputDir, | ||
{ | ||
sourcemaps: { | ||
filesToDeleteAfterUpload: fileDeletionGlobPromise, | ||
}, | ||
}, | ||
[bundler] | ||
); | ||
}); |