@enhanced-dom/webpack 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ import webpack from 'webpack';
2
+ import MemoryFS from 'memory-fs';
3
+ export declare const proxyFilesystem: (originalFilesystem: webpack.Compiler['inputFileSystem']) => MemoryFS;
4
+ export declare const patchCompilerFileSystem: (originalCompiler: webpack.Compiler, allowProxy?: boolean) => Omit<webpack.Compiler, "inputFileSystem" | "outputFileSystem"> & {
5
+ inputFileSystem: MemoryFS;
6
+ outputFileSystem: MemoryFS;
7
+ };
8
+ export declare const getInMemoryCompiler: (webpackConfig: webpack.Configuration, allowProxy?: boolean) => Omit<webpack.Compiler, "inputFileSystem" | "outputFileSystem"> & {
9
+ inputFileSystem: MemoryFS;
10
+ outputFileSystem: MemoryFS;
11
+ };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getInMemoryCompiler = exports.patchCompilerFileSystem = exports.proxyFilesystem = void 0;
7
+ const webpack_1 = __importDefault(require("webpack"));
8
+ const memory_fs_1 = __importDefault(require("memory-fs"));
9
+ const proxyFilesystem = (originalFilesystem) => {
10
+ // Inspired by: https://stackoverflow.com/questions/38779924/compiling-webpack-in-memory-but-resolving-to-node-modules-on-disk
11
+ const memFs = new memory_fs_1.default();
12
+ const statOrig = memFs.stat.bind(memFs);
13
+ const readFileOrig = memFs.readFile.bind(memFs);
14
+ memFs.stat = (filePath, cb) => {
15
+ statOrig(filePath, (err, result) => {
16
+ if (err) {
17
+ return originalFilesystem.stat(filePath, cb);
18
+ }
19
+ return cb(err, result);
20
+ });
21
+ };
22
+ memFs.readFile = (filePath, cb) => {
23
+ readFileOrig(filePath, (err, result) => {
24
+ if (err) {
25
+ return originalFilesystem.readFile(filePath, cb);
26
+ }
27
+ return cb(err, result);
28
+ });
29
+ };
30
+ return memFs;
31
+ };
32
+ exports.proxyFilesystem = proxyFilesystem;
33
+ const patchCompilerFileSystem = (originalCompiler, allowProxy = true) => {
34
+ originalCompiler.inputFileSystem = allowProxy ? (0, exports.proxyFilesystem)(originalCompiler.inputFileSystem) : new memory_fs_1.default();
35
+ originalCompiler.outputFileSystem = new memory_fs_1.default();
36
+ return originalCompiler;
37
+ };
38
+ exports.patchCompilerFileSystem = patchCompilerFileSystem;
39
+ const getInMemoryCompiler = (webpackConfig, allowProxy = true) => {
40
+ return (0, exports.patchCompilerFileSystem)((0, webpack_1.default)(webpackConfig), allowProxy);
41
+ };
42
+ exports.getInMemoryCompiler = getInMemoryCompiler;
43
+ //# sourceMappingURL=compiler.helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.helpers.js","sourceRoot":"./","sources":["compiler.helpers.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA6B;AAC7B,0DAAgC;AAEzB,MAAM,eAAe,GAAG,CAAC,kBAAuD,EAAE,EAAE;IACzF,8HAA8H;IAC9H,MAAM,KAAK,GAAG,IAAI,mBAAQ,EAAE,CAAA;IAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACvC,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/C,KAAK,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE;QAC5B,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAU,EAAE,MAAW,EAAE,EAAE;YAC7C,IAAI,GAAG,EAAE;gBACP,OAAO,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;aAC7C;YACD,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IACD,KAAK,CAAC,QAAQ,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE;QAChC,YAAY,CAAC,QAAQ,EAAE,CAAC,GAAU,EAAE,MAAW,EAAE,EAAE;YACjD,IAAI,GAAG,EAAE;gBACP,OAAO,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;aACjD;YACD,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAvBY,QAAA,eAAe,mBAuB3B;AAEM,MAAM,uBAAuB,GAAG,CAAC,gBAAkC,EAAE,UAAU,GAAG,IAAI,EAAE,EAAE;IAC/F,gBAAgB,CAAC,eAAe,GAAG,UAAU,CAAC,CAAC,CAAC,IAAA,uBAAe,EAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,mBAAQ,EAAE,CAAA;IAClH,gBAAgB,CAAC,gBAAgB,GAAG,IAAI,mBAAQ,EAAE,CAAA;IAElD,OAAO,gBAGN,CAAA;AACH,CAAC,CAAA;AARY,QAAA,uBAAuB,2BAQnC;AAEM,MAAM,mBAAmB,GAAG,CAAC,aAAoC,EAAE,UAAU,GAAG,IAAI,EAAE,EAAE;IAC7F,OAAO,IAAA,+BAAuB,EAAC,IAAA,iBAAO,EAAC,aAAa,CAAC,EAAE,UAAU,CAAC,CAAA;AACpE,CAAC,CAAA;AAFY,QAAA,mBAAmB,uBAE/B","sourcesContent":["import webpack from 'webpack'\nimport MemoryFS from 'memory-fs'\n\nexport const proxyFilesystem = (originalFilesystem: webpack.Compiler['inputFileSystem']) => {\n // Inspired by: https://stackoverflow.com/questions/38779924/compiling-webpack-in-memory-but-resolving-to-node-modules-on-disk\n const memFs = new MemoryFS()\n const statOrig = memFs.stat.bind(memFs)\n const readFileOrig = memFs.readFile.bind(memFs)\n memFs.stat = (filePath, cb) => {\n statOrig(filePath, (err: Error, result: any) => {\n if (err) {\n return originalFilesystem.stat(filePath, cb)\n }\n return cb(err, result)\n })\n }\n memFs.readFile = (filePath, cb) => {\n readFileOrig(filePath, (err: Error, result: any) => {\n if (err) {\n return originalFilesystem.readFile(filePath, cb)\n }\n return cb(err, result)\n })\n }\n\n return memFs\n}\n\nexport const patchCompilerFileSystem = (originalCompiler: webpack.Compiler, allowProxy = true) => {\n originalCompiler.inputFileSystem = allowProxy ? proxyFilesystem(originalCompiler.inputFileSystem) : new MemoryFS()\n originalCompiler.outputFileSystem = new MemoryFS()\n\n return originalCompiler as Omit<webpack.Compiler, 'inputFileSystem' | 'outputFileSystem'> & {\n inputFileSystem: MemoryFS\n outputFileSystem: MemoryFS\n }\n}\n\nexport const getInMemoryCompiler = (webpackConfig: webpack.Configuration, allowProxy = true) => {\n return patchCompilerFileSystem(webpack(webpackConfig), allowProxy)\n}\n"]}
package/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import * as loaders from './loaders';
2
2
  import * as plugins from './plugins';
3
3
  import * as configs from './configs';
4
+ import * as compiler from './compiler.helpers';
4
5
  declare const _default: {
5
6
  loaders: typeof loaders;
6
7
  plugins: typeof plugins;
7
8
  configs: typeof configs;
9
+ compiler: typeof compiler;
8
10
  };
9
11
  export = _default;
package/index.js CHANGED
@@ -25,9 +25,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  const loaders = __importStar(require("./loaders"));
26
26
  const plugins = __importStar(require("./plugins"));
27
27
  const configs = __importStar(require("./configs"));
28
+ const compiler = __importStar(require("./compiler.helpers"));
28
29
  module.exports = {
29
30
  loaders,
30
31
  plugins,
31
32
  configs,
33
+ compiler,
32
34
  };
33
35
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"./","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAoC;AACpC,mDAAoC;AACpC,mDAAoC;AACpC,iBAAS;IACP,OAAO;IACP,OAAO;IACP,OAAO;CACR,CAAA","sourcesContent":["import * as loaders from './loaders'\nimport * as plugins from './plugins'\nimport * as configs from './configs'\nexport = {\n loaders,\n plugins,\n configs,\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"./","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAoC;AACpC,mDAAoC;AACpC,mDAAoC;AACpC,6DAA8C;AAC9C,iBAAS;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,QAAQ;CACT,CAAA","sourcesContent":["import * as loaders from './loaders'\nimport * as plugins from './plugins'\nimport * as configs from './configs'\nimport * as compiler from './compiler.helpers'\nexport = {\n loaders,\n plugins,\n configs,\n compiler,\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enhanced-dom/webpack",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Helpers for webpack configuration",
5
5
  "keywords": [],
6
6
  "repository": "https://github.com/enhanced-dom/webpack.git",
@@ -9,7 +9,7 @@
9
9
  "main": "index.js",
10
10
  "dependencies": {
11
11
  "@enhanced-dom/build": "^0.0.1",
12
- "@enhanced-dom/css": "^0.0.2",
12
+ "@enhanced-dom/css": "^0.0.3",
13
13
  "@mdx-js/loader": "^2.1.1",
14
14
  "autoprefixer": "^10.3.5",
15
15
  "babel-loader": "^8.2.2",
@@ -23,6 +23,7 @@
23
23
  "html-webpack-plugin": "^5.3.1",
24
24
  "ignore-emit-webpack-plugin": "^2.0.6",
25
25
  "markdown-loader": "^8.0.0",
26
+ "memory-fs": "^0.5.0",
26
27
  "mini-css-extract-plugin": "^2.3.0",
27
28
  "null-loader": "^4.0.1",
28
29
  "css-minimizer-webpack-plugin": "^3.0.2",
@@ -48,18 +49,19 @@
48
49
  "webpack-bundle-analyzer": "^4.5.0",
49
50
  "webpack-cli": "^4.9.2",
50
51
  "webpack-dev-server": "^4.9.0",
51
- "serve": "^12.0.0"
52
+ "serve": "^14.1.2"
52
53
  },
53
54
  "devDependencies": {
54
55
  "@enhanced-dom/lint": "^0.0.7",
55
56
  "@types/html-webpack-plugin": "^3.2.5",
56
57
  "@types/loader-utils": "^2.0.2",
58
+ "@types/memory-fs": "^0.3.3",
57
59
  "@types/mini-css-extract-plugin": "^1.4.3",
58
60
  "@types/optimize-css-assets-webpack-plugin": "^5.0.3",
59
61
  "@types/terser-webpack-plugin": "^5.2.0",
60
62
  "@types/webpack": "^5.28.0",
61
63
  "@types/webpack-bundle-analyzer": "^2.9.2",
62
- "typescript": "^4.2.2"
64
+ "typescript": "^4.9.4"
63
65
  },
64
66
  "overrides": {
65
67
  "postcss": "^8.2.15",