Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow transformers to return an empty string (#2861)
- Loading branch information
1 parent
53947a1
commit 33eba89
Showing
4 changed files
with
28 additions
and
3 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,21 @@ | ||
const assert = require('assert'); | ||
|
||
const sideEffects = []; | ||
|
||
module.exports = { | ||
description: 'allows transformers to transform code to an empty string', | ||
context: { sideEffects }, | ||
exports() { | ||
assert.deepStrictEqual(sideEffects, ['this happens']); | ||
}, | ||
options: { | ||
plugins: { | ||
name: 'test-plugin', | ||
transform(code, id) { | ||
if (id.endsWith('transformed.js')) { | ||
return ''; | ||
} | ||
} | ||
} | ||
} | ||
}; |
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,3 @@ | ||
import './transformed.js'; | ||
|
||
sideEffects.push('this happens'); |
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 @@ | ||
sideEffects.push('should not happen'); |