-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow passing array of array in
config.plugins
(#1938)
<!-- Thank you for contributing! --> ### Description 1. This could allow the user or developer to compose two or more different types plugin into one, this is easy for distributing. 2. See test as an example. 3. Progressive porting js plugin. 4. Prerequisite of porting `vite:build-import-analysis` <!-- Please insert your description here and provide especially info about the "what" this PR is solving -->
- Loading branch information
1 parent
9974034
commit b4e33d5
Showing
6 changed files
with
47 additions
and
5 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
35 changes: 35 additions & 0 deletions
35
packages/rolldown/tests/fixtures/plugin/hybrid-plugin/_config.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,35 @@ | ||
import { expect } from 'vitest' | ||
import path from 'node:path' | ||
import { defineTest } from '@tests' | ||
import { loadFallbackPlugin } from 'rolldown/experimental' | ||
import { RolldownPlugin } from '@src/plugin' | ||
|
||
const entry = path.join(__dirname, './main.js') | ||
|
||
function removeConsoleForPathWithQuery(): RolldownPlugin[] { | ||
return [ | ||
loadFallbackPlugin(), | ||
{ | ||
name: 'remove-console', | ||
transform(code) { | ||
return code.replace('console.log', '') | ||
}, | ||
}, | ||
] | ||
} | ||
export default defineTest({ | ||
config: { | ||
input: entry, | ||
plugins: [ | ||
{ | ||
name: 'test-plugin', | ||
banner: () => '/* Lorem ipsum */', | ||
}, | ||
removeConsoleForPathWithQuery(), | ||
], | ||
}, | ||
afterTest: async (output) => { | ||
expect(output.output[0].code).toContain('/* Lorem ipsum */') | ||
await import('./assert.mjs') | ||
}, | ||
}) |
4 changes: 4 additions & 0 deletions
4
packages/rolldown/tests/fixtures/plugin/hybrid-plugin/assert.mjs
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,4 @@ | ||
import { a } from './dist/main' | ||
import assert from 'node:assert' | ||
|
||
assert(a === 1) |
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 @@ | ||
export const a = console.log(1) |