generated from anolilab/monorepo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added support for adding additional rollup plugins
- Loading branch information
Showing
10 changed files
with
371 additions
and
193 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { rm } from "node:fs/promises"; | ||
|
||
import { readFileSync, writeFileSync } from "@visulima/fs"; | ||
import type { Plugin } from "rollup"; | ||
import { temporaryDirectory } from "tempy"; | ||
import { afterEach, beforeEach, describe, expect, it } from "vitest"; | ||
|
||
import { createPackageJson, createPackemConfig, createTsConfig, execPackemSync, installPackage } from "../helpers"; | ||
|
||
describe("packem build --jit", () => { | ||
let temporaryDirectoryPath: string; | ||
|
||
beforeEach(async () => { | ||
temporaryDirectoryPath = temporaryDirectory(); | ||
}); | ||
|
||
afterEach(async () => { | ||
await rm(temporaryDirectoryPath, { recursive: true }); | ||
}); | ||
|
||
it("should append plugins before and after a named plugin", async () => { | ||
expect.assertions(4); | ||
|
||
await installPackage(temporaryDirectoryPath, "typescript"); | ||
|
||
writeFileSync(`${temporaryDirectoryPath}/src/index.ts`, `export default () => 'index';`); | ||
|
||
createTsConfig(temporaryDirectoryPath, {}); | ||
createPackageJson(temporaryDirectoryPath, { | ||
devDependencies: { | ||
typescript: "*", | ||
}, | ||
main: "./dist/index.cjs", | ||
}); | ||
await createPackemConfig( | ||
temporaryDirectoryPath, | ||
`rollup: { | ||
plugins: [ | ||
{ | ||
before: "packem:esbuild", | ||
plugin: <Plugin>{ | ||
load() { | ||
console.log("packem:test-plugin:before"); | ||
}, | ||
name: "packem:test-plugin:before" | ||
} | ||
}, | ||
{ | ||
after: "packem:esbuild", | ||
plugin: <Plugin>{ | ||
load() { | ||
console.log("packem:test-plugin:after"); | ||
}, | ||
name: "packem:test-plugin:after" | ||
} | ||
} | ||
] | ||
}`, | ||
); | ||
|
||
const binProcess = await execPackemSync("build", [], { | ||
cwd: temporaryDirectoryPath, | ||
}); | ||
|
||
expect(binProcess.stderr).toBe(""); | ||
expect(binProcess.exitCode).toBe(0); | ||
|
||
expect(binProcess.stdout).toContain("packem:test-plugin:before"); | ||
expect(binProcess.stdout).toContain("packem:test-plugin:after"); | ||
}); | ||
}); |
Oops, something went wrong.