Skip to content

Commit

Permalink
let the plugin can access to loader context info
Browse files Browse the repository at this point in the history
swc-project#36 
maybe this will be more flexible
  • Loading branch information
ssddi456 authored Jul 13, 2022
1 parent 4697faf commit 6eec5e6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ function makeLoader() {
programmaticOptions.sourceMaps = true;
}

if (programmaticOptions.plugin) {
const passInPlugin = programmaticOptions.plugin;
programmaticOptions.plugin = (m) => {
return passInPlugin(m, this);
};
}

try {
if (sync) {
const output = swc.transformSync(source, programmaticOptions);
Expand Down

0 comments on commit 6eec5e6

Please sign in to comment.