[6a3a178] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
---|
| 4 | value: true
|
---|
| 5 | });
|
---|
| 6 | exports.default = setupOutputFileSystem;
|
---|
| 7 |
|
---|
| 8 | var _path = _interopRequireDefault(require("path"));
|
---|
| 9 |
|
---|
| 10 | var _memfs = require("memfs");
|
---|
| 11 |
|
---|
| 12 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
---|
| 13 |
|
---|
| 14 | function setupOutputFileSystem(context) {
|
---|
| 15 | let outputFileSystem;
|
---|
| 16 |
|
---|
| 17 | if (context.options.outputFileSystem) {
|
---|
| 18 | // eslint-disable-next-line no-shadow
|
---|
| 19 | const {
|
---|
| 20 | outputFileSystem: outputFileSystemFromOptions
|
---|
| 21 | } = context.options; // Todo remove when we drop webpack@4 support
|
---|
| 22 |
|
---|
| 23 | if (typeof outputFileSystemFromOptions.join !== "function") {
|
---|
| 24 | throw new Error("Invalid options: options.outputFileSystem.join() method is expected");
|
---|
| 25 | } // Todo remove when we drop webpack@4 support
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | if (typeof outputFileSystemFromOptions.mkdirp !== "function") {
|
---|
| 29 | throw new Error("Invalid options: options.outputFileSystem.mkdirp() method is expected");
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | outputFileSystem = outputFileSystemFromOptions;
|
---|
| 33 | } else {
|
---|
| 34 | outputFileSystem = (0, _memfs.createFsFromVolume)(new _memfs.Volume()); // TODO: remove when we drop webpack@4 support
|
---|
| 35 |
|
---|
| 36 | outputFileSystem.join = _path.default.join.bind(_path.default);
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | const compilers = context.compiler.compilers || [context.compiler];
|
---|
| 40 |
|
---|
| 41 | for (const compiler of compilers) {
|
---|
| 42 | // eslint-disable-next-line no-param-reassign
|
---|
| 43 | compiler.outputFileSystem = outputFileSystem;
|
---|
| 44 | } // eslint-disable-next-line no-param-reassign
|
---|
| 45 |
|
---|
| 46 |
|
---|
| 47 | context.outputFileSystem = outputFileSystem;
|
---|
| 48 | } |
---|