From 31be0606ec287e7c028b1fa71552da329a195223 Mon Sep 17 00:00:00 2001 From: Peter Somogyvari Date: Thu, 12 Nov 2020 12:38:29 -0800 Subject: [PATCH] build(webpack): adds shebang loader Added a shebang-loader (webpack plugin) to avoid webpack disappearing the hashbang from the standard bin script of the example package. Without this, if you have the shebang at the beginning of your Typescript file such as this And then build the project, it would just disappear, but with the shebang loader it is preserved. Signed-off-by: Peter Somogyvari --- package-lock.json | 36 +++++++++++++++++++++++++++++++++++- package.json | 1 + webpack.dev.node.js | 4 ++++ webpack.prod.node.js | 4 ++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 6f70bfe0b3..6d9340e0ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3961,6 +3961,16 @@ "integrity": "sha512-3/qRXczDi2Cdbz6jE+W3IflJOutRVica8frpBn14de1mBOkzDo+6tY33kNhvkw54Kn3PzRRD2VnGbGPcTAk4sw==", "dev": true }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dev": true, + "optional": true, + "requires": { + "file-uri-to-path": "1.0.0" + } + }, "blob": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", @@ -7417,6 +7427,13 @@ "escape-string-regexp": "^1.0.5" } }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "dev": true, + "optional": true + }, "filesize": { "version": "3.6.1", "resolved": "https://registry.npmjs.org/filesize/-/filesize-3.6.1.tgz", @@ -11322,6 +11339,13 @@ "thenify-all": "^1.0.0" } }, + "nan": { + "version": "2.14.2", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz", + "integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==", + "dev": true, + "optional": true + }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -13545,6 +13569,12 @@ "shebang-regex": "^1.0.0" } }, + "shebang-loader": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/shebang-loader/-/shebang-loader-0.0.1.tgz", + "integrity": "sha1-pAAEldRMzu++xjQ157FphWn6Uuw=", + "dev": true + }, "shebang-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", @@ -16915,7 +16945,11 @@ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", "dev": true, - "optional": true + "optional": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + } }, "glob-parent": { "version": "3.1.0", diff --git a/package.json b/package.json index f39daa35a6..90bffa5d18 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "npm-run-all": "4.1.5", "prettier": "2.0.5", "secp256k1": "4.0.0", + "shebang-loader": "0.0.1", "source-map-loader": "0.2.4", "tap": "14.10.6", "tape": "5.0.1", diff --git a/webpack.dev.node.js b/webpack.dev.node.js index 2bca39d62b..5e9f6f36cf 100644 --- a/webpack.dev.node.js +++ b/webpack.dev.node.js @@ -17,6 +17,10 @@ module.exports = { devtool: "inline-source-map", module: { rules: [ + { + test: /\.(js|ts)$/, + use: ["shebang-loader"], + }, { test: /\.ts$/, exclude: /node_modules/, diff --git a/webpack.prod.node.js b/webpack.prod.node.js index 939ef13ea6..92b7bc498e 100644 --- a/webpack.prod.node.js +++ b/webpack.prod.node.js @@ -17,6 +17,10 @@ module.exports = { devtool: "source-map", module: { rules: [ + { + test: /\.(js|ts)$/, + use: ["shebang-loader"], + }, { test: /\.ts$/, exclude: /node_modules/,