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: | diff --git a/templates/typescript_gapic/package.json.njk b/templates/typescript_gapic/package.json.njk index b9d87bfbe..3c4429a80 100644 --- a/templates/typescript_gapic/package.json.njk +++ b/templates/typescript_gapic/package.json.njk @@ -57,8 +57,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" }, "engines": { "node": ">=8.13.0" 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/package.json.baseline b/typescript/test/testdata/keymanager/package.json.baseline index c1853e9df..2d42bc441 100644 --- a/typescript/test/testdata/keymanager/package.json.baseline +++ b/typescript/test/testdata/keymanager/package.json.baseline @@ -40,8 +40,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" }, "engines": { "node": ">=8.13.0" 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/package.json.baseline b/typescript/test/testdata/showcase/package.json.baseline index 83ccb08c0..ff92b5970 100644 --- a/typescript/test/testdata/showcase/package.json.baseline +++ b/typescript/test/testdata/showcase/package.json.baseline @@ -40,8 +40,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" }, "engines": { "node": ">=8.13.0" 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/package.json.baseline b/typescript/test/testdata/texttospeech/package.json.baseline index 9ab588f6c..a5c823829 100644 --- a/typescript/test/testdata/texttospeech/package.json.baseline +++ b/typescript/test/testdata/texttospeech/package.json.baseline @@ -40,8 +40,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" }, "engines": { "node": ">=8.13.0" 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/package.json.baseline b/typescript/test/testdata/translate/package.json.baseline index 0340609d2..3aeea6255 100644 --- a/typescript/test/testdata/translate/package.json.baseline +++ b/typescript/test/testdata/translate/package.json.baseline @@ -40,8 +40,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" }, "engines": { "node": ">=8.13.0" 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', +};