Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add resolved sources to shouldTransformCachedModule (#4414)
* Add dependencies to shouldTransform hook * Test errors in shouldTransform are handled correctly * Provide resolvedSources instead of importedIds * Add documentation
- Loading branch information
1 parent
3106ec9
commit 7cc87f1
Showing
7 changed files
with
99 additions
and
8 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
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
44 changes: 44 additions & 0 deletions
44
test/function/samples/plugin-error-should-transform/_config.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,44 @@ | ||
const path = require('path'); | ||
const acorn = require('acorn'); | ||
|
||
const code = 'export default 42;\n'; | ||
const ID_MAIN = path.join(__dirname, 'main.js'); | ||
|
||
module.exports = { | ||
description: 'errors in shouldTransformCachedModule abort the build', | ||
options: { | ||
cache: { | ||
modules: [ | ||
{ | ||
id: ID_MAIN, | ||
ast: acorn.parse(code, { | ||
ecmaVersion: 6, | ||
sourceType: 'module' | ||
}), | ||
code, | ||
dependencies: [], | ||
dynamicDependencies: [], | ||
originalCode: code, | ||
resolvedIds: {}, | ||
sourcemapChain: [], | ||
transformDependencies: [] | ||
} | ||
] | ||
}, | ||
plugins: [ | ||
{ | ||
name: 'test', | ||
shouldTransformCachedModule() { | ||
throw new Error('broken'); | ||
} | ||
} | ||
] | ||
}, | ||
error: { | ||
code: 'PLUGIN_ERROR', | ||
hook: 'shouldTransformCachedModule', | ||
message: 'broken', | ||
plugin: 'test', | ||
watchFiles: [ID_MAIN] | ||
} | ||
}; |
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 default 42; |
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