From 9d2796b3e37ce3a979ca8e0613af3450d4c38919 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Tue, 12 Nov 2019 14:46:39 -0800 Subject: [PATCH 1/3] generate webpack config js --- .../typescript_gapic/webpack.config.js.njk | 64 +++++++++++++++++++ .../keymanager/webpack.config.js.baseline | 64 +++++++++++++++++++ .../showcase/webpack.config.js.baseline | 64 +++++++++++++++++++ .../texttospeech/webpack.config.js.baseline | 64 +++++++++++++++++++ .../translate/webpack.config.js.baseline | 64 +++++++++++++++++++ 5 files changed, 320 insertions(+) create mode 100644 templates/typescript_gapic/webpack.config.js.njk create mode 100644 typescript/test/testdata/keymanager/webpack.config.js.baseline create mode 100644 typescript/test/testdata/showcase/webpack.config.js.baseline create mode 100644 typescript/test/testdata/texttospeech/webpack.config.js.baseline create mode 100644 typescript/test/testdata/translate/webpack.config.js.baseline diff --git a/templates/typescript_gapic/webpack.config.js.njk b/templates/typescript_gapic/webpack.config.js.njk new file mode 100644 index 000000000..084218ca4 --- /dev/null +++ b/templates/typescript_gapic/webpack.config.js.njk @@ -0,0 +1,64 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: '{{ api.naming.name.toCamelCase() }}', + filename: './{{ api.naming.name.toKebabCase() }}.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\\/]@grpc[\\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]https-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/typescript/test/testdata/keymanager/webpack.config.js.baseline b/typescript/test/testdata/keymanager/webpack.config.js.baseline new file mode 100644 index 000000000..e07e16fe0 --- /dev/null +++ b/typescript/test/testdata/keymanager/webpack.config.js.baseline @@ -0,0 +1,64 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'kms', + filename: './kms.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\\/]@grpc[\\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]https-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/typescript/test/testdata/showcase/webpack.config.js.baseline b/typescript/test/testdata/showcase/webpack.config.js.baseline new file mode 100644 index 000000000..cea49a3b3 --- /dev/null +++ b/typescript/test/testdata/showcase/webpack.config.js.baseline @@ -0,0 +1,64 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'showcase', + filename: './showcase.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\\/]@grpc[\\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]https-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/typescript/test/testdata/texttospeech/webpack.config.js.baseline b/typescript/test/testdata/texttospeech/webpack.config.js.baseline new file mode 100644 index 000000000..eb885db73 --- /dev/null +++ b/typescript/test/testdata/texttospeech/webpack.config.js.baseline @@ -0,0 +1,64 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'texttospeech', + filename: './texttospeech.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\\/]@grpc[\\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]https-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/typescript/test/testdata/translate/webpack.config.js.baseline b/typescript/test/testdata/translate/webpack.config.js.baseline new file mode 100644 index 000000000..85d02382f --- /dev/null +++ b/typescript/test/testdata/translate/webpack.config.js.baseline @@ -0,0 +1,64 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'translation', + filename: './translation.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\\/]@grpc[\\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]https-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; From aefef33be73a38265fea00f2177a3a3df02d1012 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Tue, 12 Nov 2019 15:41:58 -0800 Subject: [PATCH 2/3] fux --- templates/typescript_gapic/package.json.njk | 6 +++++- typescript/test/testdata/keymanager/package.json.baseline | 6 +++++- typescript/test/testdata/showcase/package.json.baseline | 6 +++++- typescript/test/testdata/texttospeech/package.json.baseline | 6 +++++- typescript/test/testdata/translate/package.json.baseline | 6 +++++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/templates/typescript_gapic/package.json.njk b/templates/typescript_gapic/package.json.njk index bb6f6480e..6dffa5649 100644 --- a/templates/typescript_gapic/package.json.njk +++ b/templates/typescript_gapic/package.json.njk @@ -40,8 +40,12 @@ limitations under the License. "mocha": "^6.0.0", "mv": "^2.1.1", "ncp": "^2.0.0", + "null-loader": "^3.0.0", "tmp": "^0.1.0", - "typescript": "^3.7.0" + "ts-loader": "^6.2.1", + "typescript": "^3.7.0", + "webpack": "^4.41.2", + "webpack-cli": "^3.3.10" }, "scripts": { "lint": "gts check", diff --git a/typescript/test/testdata/keymanager/package.json.baseline b/typescript/test/testdata/keymanager/package.json.baseline index 6efdd7e3f..c821d0d67 100644 --- a/typescript/test/testdata/keymanager/package.json.baseline +++ b/typescript/test/testdata/keymanager/package.json.baseline @@ -23,8 +23,12 @@ "mocha": "^6.0.0", "mv": "^2.1.1", "ncp": "^2.0.0", + "null-loader": "^3.0.0", "tmp": "^0.1.0", - "typescript": "^3.7.0" + "ts-loader": "^6.2.1", + "typescript": "^3.7.0", + "webpack": "^4.41.2", + "webpack-cli": "^3.3.10" }, "scripts": { "lint": "gts check", diff --git a/typescript/test/testdata/showcase/package.json.baseline b/typescript/test/testdata/showcase/package.json.baseline index 5d690961e..303e10dfa 100644 --- a/typescript/test/testdata/showcase/package.json.baseline +++ b/typescript/test/testdata/showcase/package.json.baseline @@ -23,8 +23,12 @@ "mocha": "^6.0.0", "mv": "^2.1.1", "ncp": "^2.0.0", + "null-loader": "^3.0.0", "tmp": "^0.1.0", - "typescript": "^3.7.0" + "ts-loader": "^6.2.1", + "typescript": "^3.7.0", + "webpack": "^4.41.2", + "webpack-cli": "^3.3.10" }, "scripts": { "lint": "gts check", diff --git a/typescript/test/testdata/texttospeech/package.json.baseline b/typescript/test/testdata/texttospeech/package.json.baseline index 84e222e36..e3b9adb07 100644 --- a/typescript/test/testdata/texttospeech/package.json.baseline +++ b/typescript/test/testdata/texttospeech/package.json.baseline @@ -23,8 +23,12 @@ "mocha": "^6.0.0", "mv": "^2.1.1", "ncp": "^2.0.0", + "null-loader": "^3.0.0", "tmp": "^0.1.0", - "typescript": "^3.7.0" + "ts-loader": "^6.2.1", + "typescript": "^3.7.0", + "webpack": "^4.41.2", + "webpack-cli": "^3.3.10" }, "scripts": { "lint": "gts check", diff --git a/typescript/test/testdata/translate/package.json.baseline b/typescript/test/testdata/translate/package.json.baseline index c34b51122..45172b70f 100644 --- a/typescript/test/testdata/translate/package.json.baseline +++ b/typescript/test/testdata/translate/package.json.baseline @@ -23,8 +23,12 @@ "mocha": "^6.0.0", "mv": "^2.1.1", "ncp": "^2.0.0", + "null-loader": "^3.0.0", "tmp": "^0.1.0", - "typescript": "^3.7.0" + "ts-loader": "^6.2.1", + "typescript": "^3.7.0", + "webpack": "^4.41.2", + "webpack-cli": "^3.3.10" }, "scripts": { "lint": "gts check", From 537a1ab4bdb54b477d30cc042df467e9122e922b Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Tue, 12 Nov 2019 16:59:31 -0800 Subject: [PATCH 3/3] add webpack check to circleCI --- .circleci/config.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6e464166a..22c9da49b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,7 +63,7 @@ jobs: npm run browser-test trap stop_showcase EXIT - run: - name: Run unit tests, system tests, jsdoc generation, and gts fix of the generated Showcase library + name: Run unit tests, system tests, jsdoc generation, gts fix and generate webpack of the generated Showcase library command: | cd .test-out-showcase npm install @@ -73,8 +73,9 @@ jobs: npm run system-test npm run docs npm run docs-test + npx webpack - run: - name: Run unit tests, system tests, jsdoc generation, and gts fix of the generated KMS library + name: Run unit tests, system tests, jsdoc generation, gts fix and generate webpack of the generated KMS library command: | cp -r typescript/test/protos ./.test-out-keymanager cd .test-out-keymanager @@ -85,8 +86,9 @@ jobs: npm run system-test npm run docs npm run docs-test + npx webpack - run: - name: Run unit tests, system tests, jsdoc generation, and gts fix of the generated Translate library + name: Run unit tests, system tests, jsdoc generation, gts fix and generate webpack of the generated Translate library command: | cp -r typescript/test/protos ./.test-out-translate cd .test-out-translate @@ -97,8 +99,9 @@ jobs: npm run system-test npm run docs npm run docs-test + npx webpack - run: - name: Run unit tests, system tests, jsdoc generation, and gts fix of the generated Text-to-Speech library + name: Run unit tests, system tests, jsdoc generation, gts fix and generate webpack of the generated Text-to-Speech library command: | cp -r typescript/test/protos ./.test-out-texttospeech cd .test-out-texttospeech @@ -109,6 +112,7 @@ jobs: npm run system-test npm run docs npm run docs-test + npx webpack - run: name: Run linting command: |