Skip to content

Commit 5d82810

Browse files
committed
Update Webpack plugin
1 parent 948d29b commit 5d82810

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

packages/snaps-webpack-plugin/src/__snapshots__/plugin.test.ts.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
exports[`SnapsWebpackPlugin applies a transform 1`] = `
44
"(() => {
5-
var __webpack_exports__ = {};
65
const foo = 'bar';
76
})();"
87
`;
98

109
exports[`SnapsWebpackPlugin forwards the options 1`] = `
1110
"/******/(() => {
1211
// webpackBootstrap
13-
var __webpack_exports__ = {};
1412
1513
// foo bar
1614
/* baz qux */

packages/snaps-webpack-plugin/src/plugin.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ const bundle = async ({
6161
...webpackOptions,
6262
});
6363

64-
bundler.inputFileSystem = fileSystem;
65-
bundler.outputFileSystem = fileSystem;
64+
bundler.inputFileSystem = fileSystem as unknown as webpack.InputFileSystem;
65+
bundler.outputFileSystem = fileSystem as unknown as webpack.OutputFileSystem;
6666

6767
await fs.mkdir('/lib', { recursive: true });
6868
await fs.writeFile('/foo.js', code);

packages/snaps-webpack-plugin/src/plugin.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,11 @@ export default class SnapsWebpackPlugin {
128128

129129
const filePath = pathUtils.join(outputPath, file.name);
130130

131+
const fs = compiler.outputFileSystem;
132+
assert(fs, 'Expected compiler to have an output file system.');
133+
131134
const bundleFile = await promisify(
132-
compiler.outputFileSystem.readFile.bind(compiler.outputFileSystem),
135+
fs.readFile.bind(compiler.outputFileSystem),
133136
)(filePath);
134137
assert(bundleFile);
135138

@@ -148,11 +151,7 @@ export default class SnapsWebpackPlugin {
148151
updateAndWriteManifest: this.options.writeManifest,
149152
sourceCode: bundleContent,
150153
writeFileFn: async (path, data) => {
151-
return writeManifest(
152-
path,
153-
data,
154-
promisify(compiler.outputFileSystem.writeFile),
155-
);
154+
return writeManifest(path, data, promisify(fs.writeFile));
156155
},
157156
},
158157
);

0 commit comments

Comments
 (0)