From 285712bfc76a26adfb9348fdffa17d66d03d9ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 29 Jun 2021 17:31:01 +0200 Subject: [PATCH] Fixing building of typings --- .github/workflows/push-to-npm.yml | 4 ---- front/package.json | 1 + front/webpack.config.ts | 17 ++++++++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/push-to-npm.yml b/.github/workflows/push-to-npm.yml index 43542c28..011ae440 100644 --- a/.github/workflows/push-to-npm.yml +++ b/.github/workflows/push-to-npm.yml @@ -13,10 +13,6 @@ jobs: node-version: '14.x' registry-url: 'https://registry.npmjs.org' - - name: Edit tsconfig.json to add declarations - run: "sed -i 's/\"declaration\": false/\"declaration\": true/g' tsconfig.json" - working-directory: "front" - - name: Replace version number run: 'sed -i "s#VERSION_PLACEHOLDER#${GITHUB_REF/refs\/tags\//}#g" package.json' working-directory: "front/packages/iframe-api-typings" diff --git a/front/package.json b/front/package.json index 1c938195..077b992f 100644 --- a/front/package.json +++ b/front/package.json @@ -52,6 +52,7 @@ "scripts": { "start": "TS_NODE_PROJECT=\"tsconfig-for-webpack.json\" webpack serve --open", "build": "TS_NODE_PROJECT=\"tsconfig-for-webpack.json\" NODE_ENV=production webpack", + "build-typings": "TS_NODE_PROJECT=\"tsconfig-for-webpack.json\" NODE_ENV=production NODE_ENV=production BUILD_TYPINGS=1 webpack", "test": "TS_NODE_PROJECT=\"tsconfig-for-jasmine.json\" ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json", "lint": "node_modules/.bin/eslint src/ . --ext .ts", "fix": "node_modules/.bin/eslint --fix src/ . --ext .ts" diff --git a/front/webpack.config.ts b/front/webpack.config.ts index 3a69b74a..04ad8445 100644 --- a/front/webpack.config.ts +++ b/front/webpack.config.ts @@ -10,14 +10,18 @@ import NodePolyfillPlugin from 'node-polyfill-webpack-plugin'; import {DISPLAY_TERMS_OF_USE} from "./src/Enum/EnvironmentVariable"; const mode = process.env.NODE_ENV ?? 'development'; +const buildNpmTypingsForApi = !!process.env.BUILD_TYPINGS; const isProduction = mode === 'production'; const isDevelopment = !isProduction; +let entries: { [key: string]: string; } = {}; +if (!buildNpmTypingsForApi) { + entries.main = './src/index.ts'; +} +entries.iframe_api = './src/iframe_api.ts'; + module.exports = { - entry: { - 'main': './src/index.ts', - 'iframe_api': './src/iframe_api.ts' - }, + entry: entries, mode: mode, devtool: isDevelopment ? 'inline-source-map' : 'source-map', devServer: { @@ -40,7 +44,10 @@ module.exports = { exclude: /node_modules/, loader: 'ts-loader', options: { - transpileOnly: true, + transpileOnly: !buildNpmTypingsForApi, + compilerOptions: { + declaration: buildNpmTypingsForApi + } }, }, {