Skip to content

Commit

Permalink
fix: allow TypeScript in V14 server bootstrapping mode (#10656)
Browse files Browse the repository at this point in the history
* fix: allow TypeScript in V14 server bootstrapping mode

Fixes #10414

* Fix fork-ts-checker-plugin options

* fix: disable resolving TypeScript when no tsconfig.json
  • Loading branch information
platosha committed Apr 19, 2021
1 parent bba8d70 commit 9cb84c2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ static Map<String, String> getDefaultDevDependencies() {
defaults.put("html-webpack-plugin", "4.5.1");
defaults.put("typescript", "4.2.3");
defaults.put("ts-loader", "8.0.12");
defaults.put("fork-ts-checker-webpack-plugin", "6.2.1");

defaults.put("webpack", "4.46.0");
defaults.put("webpack-cli", "3.3.11");
Expand Down
19 changes: 16 additions & 3 deletions flow-server/src/main/resources/webpack.generated.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const { InjectManifest } = require('workbox-webpack-plugin');
const { DefinePlugin } = require('webpack');
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

// Flow plugins
const StatsPlugin = require('@vaadin/stats-plugin');
Expand Down Expand Up @@ -67,6 +68,8 @@ const themeProjectFolders = projectStaticAssetsFolders.map((folder) =>
path.resolve(folder, 'themes')
);

const tsconfigJsonFile = path.resolve(__dirname, 'tsconfig.json');
const enableTypeScript = fs.existsSync(tsconfigJsonFile);

// Target flow-fronted auto generated to be the actual target folder
const flowFrontendFolder = '[to-be-generated-by-flow]';
Expand Down Expand Up @@ -212,7 +215,7 @@ module.exports = {
...projectStaticAssetsFolders,
],
extensions: [
useClientSideIndexFileForBootstrapping && '.ts',
enableTypeScript && '.ts',
'.js'
].filter(Boolean),
alias: {
Expand Down Expand Up @@ -243,9 +246,13 @@ module.exports = {

module: {
rules: [
useClientSideIndexFileForBootstrapping && {
enableTypeScript && {
test: /\.ts$/,
loader: 'ts-loader'
loader: 'ts-loader',
options: {
transpileOnly: true,
experimentalWatchApi: true
}
},
{
test: /\.css$/i,
Expand Down Expand Up @@ -342,5 +349,11 @@ module.exports = {

// Generate compressed bundles when not devMode
!devMode && new CompressionPlugin(),

enableTypeScript && new ForkTsCheckerWebpackPlugin({
typescript: {
configFile: tsconfigJsonFile
}
}),
].filter(Boolean)
};

0 comments on commit 9cb84c2

Please sign in to comment.