From d1fedf86a6dffe62289c36cc1b5b5db0b1ee287a Mon Sep 17 00:00:00 2001 From: lakatostamas Date: Sat, 5 Jan 2019 13:14:05 +0100 Subject: [PATCH 1/5] fix(bin): extension detection (#724) --- bin/convert-argv.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/convert-argv.js b/bin/convert-argv.js index c5fe4e59076..92842b9d693 100644 --- a/bin/convert-argv.js +++ b/bin/convert-argv.js @@ -69,15 +69,17 @@ module.exports = function(...args) { const configArgList = Array.isArray(argv.config) ? argv.config : [argv.config]; configFiles = configArgList.map(mapConfigArg); } else { - const defaultConfigFiles = ["webpack.config", "webpackfile"]; - const webpackConfigFileRegExp = `(${defaultConfigFiles.join("|")})(${extensions.join("|")})`; + const defaultConfigFileNames = ["webpack.config", "webpackfile"].join("|"); + const webpackConfigFileRegExp = `(${defaultConfigFileNames})(${extensions.join("|")})`; const pathToWebpackConfig = findup(webpackConfigFileRegExp); if (pathToWebpackConfig) { const resolvedPath = path.resolve(pathToWebpackConfig); + const actualConfigFileName = path.basename(resolvedPath); + const ext = actualConfigFileName.replace(new RegExp(defaultConfigFileNames), ""); configFiles.push({ path: resolvedPath, - ext: resolvedPath.split(".").pop() + ext, }); } } From 12e602d36feb0d04469a81fb29cf8096e1ffeb97 Mon Sep 17 00:00:00 2001 From: lakatostamas Date: Sun, 6 Jan 2019 19:04:42 +0100 Subject: [PATCH 2/5] tests(bin): add `webpack.config.babel.js` related test (#724) --- .../webpack-babel-config/index2.js | 1 + .../webpack-babel-config.test.js | 17 +++++++++++++++++ .../webpack.config.babel.js | 9 +++++++++ 3 files changed, 27 insertions(+) create mode 100644 test/binCases/config-location/webpack-babel-config/index2.js create mode 100644 test/binCases/config-location/webpack-babel-config/webpack-babel-config.test.js create mode 100644 test/binCases/config-location/webpack-babel-config/webpack.config.babel.js diff --git a/test/binCases/config-location/webpack-babel-config/index2.js b/test/binCases/config-location/webpack-babel-config/index2.js new file mode 100644 index 00000000000..c4a0814534f --- /dev/null +++ b/test/binCases/config-location/webpack-babel-config/index2.js @@ -0,0 +1 @@ +module.exports = "webpack-babel-config"; diff --git a/test/binCases/config-location/webpack-babel-config/webpack-babel-config.test.js b/test/binCases/config-location/webpack-babel-config/webpack-babel-config.test.js new file mode 100644 index 00000000000..2010632c1d1 --- /dev/null +++ b/test/binCases/config-location/webpack-babel-config/webpack-babel-config.test.js @@ -0,0 +1,17 @@ +"use strict"; + +const { run } = require("../../../testUtils"); + +test("webpack-babel-config", () => { + const { code, stdout, stderr } = run(__dirname, [ + "--output-filename", + "[name].js", + "--output-chunk-filename", + "[id].chunk.js", + "--target", + "async-node", + ]); + expect(code).toBe(0); + expect(stdout).toContain("./index2.js"); + expect(stderr).toHaveLength(0); +}); diff --git a/test/binCases/config-location/webpack-babel-config/webpack.config.babel.js b/test/binCases/config-location/webpack-babel-config/webpack.config.babel.js new file mode 100644 index 00000000000..af76b2c7870 --- /dev/null +++ b/test/binCases/config-location/webpack-babel-config/webpack.config.babel.js @@ -0,0 +1,9 @@ +// eslint-disable-next-line node/no-unsupported-features, node/no-unsupported-features/es-syntax +import path from "path"; + +const config = { + entry: path.resolve(__dirname, "./index2") +}; + +// eslint-disable-next-line node/no-unsupported-features, node/no-unsupported-features/es-syntax +export default config; From 1330f65600e90a167b2ee9bce1249c85dbca3923 Mon Sep 17 00:00:00 2001 From: lakatostamas Date: Sun, 6 Jan 2019 19:59:52 +0100 Subject: [PATCH 3/5] tests(bin): add `.babelrc` to webpack-babel-config test (#724) --- test/binCases/config-location/webpack-babel-config/.babelrc | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 test/binCases/config-location/webpack-babel-config/.babelrc diff --git a/test/binCases/config-location/webpack-babel-config/.babelrc b/test/binCases/config-location/webpack-babel-config/.babelrc new file mode 100644 index 00000000000..0f4b58f6843 --- /dev/null +++ b/test/binCases/config-location/webpack-babel-config/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["env"] +} From 7580b48956b8496d0ed901371438680cca5b4bc6 Mon Sep 17 00:00:00 2001 From: lakatostamas Date: Sun, 6 Jan 2019 22:06:50 +0100 Subject: [PATCH 4/5] chore(dependency): add `node-ts` as devDependency (#724) --- package-lock.json | 40 ++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 41 insertions(+) diff --git a/package-lock.json b/package-lock.json index 6ebfd7ef863..7d91de9ecb2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17204,6 +17204,40 @@ } } }, + "ts-node": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz", + "integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==", + "dev": true, + "requires": { + "arrify": "^1.0.0", + "buffer-from": "^1.1.0", + "diff": "^3.1.0", + "make-error": "^1.1.1", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "source-map-support": "^0.5.6", + "yn": "^2.0.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "source-map-support": { + "version": "0.5.9", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.9.tgz", + "integrity": "sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + } + } + }, "tslib": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", @@ -18400,6 +18434,12 @@ "camelcase": "^5.0.0", "decamelize": "^1.2.0" } + }, + "yn": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", + "integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=", + "dev": true } } } diff --git a/package.json b/package.json index 359fa8ad2a7..fcb331f1c5a 100644 --- a/package.json +++ b/package.json @@ -152,6 +152,7 @@ "rimraf": "^2.6.2", "schema-utils": "^1.0.0", "ts-jest": "^23.10.4", + "ts-node": "^7.0.1", "tslint": "^5.11.0", "typedoc": "^0.13.0", "typedoc-plugin-monorepo": "^0.1.0", From 8dc59990738e8bc5611f95a3ca89ee2a6e37480b Mon Sep 17 00:00:00 2001 From: lakatostamas Date: Sun, 6 Jan 2019 22:08:15 +0100 Subject: [PATCH 5/5] tests(bin): add `webpack.config.ts` related test (#724) --- .../config-location/webpack-ts-config/index2.js | 1 + .../webpack-ts-config/tsconfig.json | 5 +++++ .../webpack-ts-config/webpack-ts-config.test.js | 17 +++++++++++++++++ .../webpack-ts-config/webpack.config.ts | 8 ++++++++ 4 files changed, 31 insertions(+) create mode 100644 test/binCases/config-location/webpack-ts-config/index2.js create mode 100644 test/binCases/config-location/webpack-ts-config/tsconfig.json create mode 100644 test/binCases/config-location/webpack-ts-config/webpack-ts-config.test.js create mode 100644 test/binCases/config-location/webpack-ts-config/webpack.config.ts diff --git a/test/binCases/config-location/webpack-ts-config/index2.js b/test/binCases/config-location/webpack-ts-config/index2.js new file mode 100644 index 00000000000..eb252a9f270 --- /dev/null +++ b/test/binCases/config-location/webpack-ts-config/index2.js @@ -0,0 +1 @@ +module.exports = "webpack-ts-config"; diff --git a/test/binCases/config-location/webpack-ts-config/tsconfig.json b/test/binCases/config-location/webpack-ts-config/tsconfig.json new file mode 100644 index 00000000000..2f98042715a --- /dev/null +++ b/test/binCases/config-location/webpack-ts-config/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "esModuleInterop": true + } +} diff --git a/test/binCases/config-location/webpack-ts-config/webpack-ts-config.test.js b/test/binCases/config-location/webpack-ts-config/webpack-ts-config.test.js new file mode 100644 index 00000000000..2139a5b97c9 --- /dev/null +++ b/test/binCases/config-location/webpack-ts-config/webpack-ts-config.test.js @@ -0,0 +1,17 @@ +"use strict"; + +const { run } = require("../../../testUtils"); + +test("webpack-ts-config", () => { + const { code, stdout, stderr } = run(__dirname, [ + "--output-filename", + "[name].js", + "--output-chunk-filename", + "[id].chunk.js", + "--target", + "async-node", + ]); + expect(code).toBe(0); + expect(stdout).toContain("./index2.js"); + expect(stderr).toHaveLength(0); +}); diff --git a/test/binCases/config-location/webpack-ts-config/webpack.config.ts b/test/binCases/config-location/webpack-ts-config/webpack.config.ts new file mode 100644 index 00000000000..0e6c3d09d23 --- /dev/null +++ b/test/binCases/config-location/webpack-ts-config/webpack.config.ts @@ -0,0 +1,8 @@ +import path from "path"; +import webpack from "webpack"; + +const config: webpack.Configuration = { + entry: path.resolve(__dirname, "./index2"), +}; + +export default config;