Skip to content

Commit

Permalink
Merge pull request #16 from JakeSidSmith/fix-include
Browse files Browse the repository at this point in the history
Fix include
  • Loading branch information
JakeSidSmith authored Jan 18, 2021
2 parents e0ea110 + e058ebc commit 4263981
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jakesidsmith/tsb",
"version": "0.1.3",
"version": "0.1.4",
"description": "Dead simple TypeScript bundler, watcher, dev server, transpiler, and polyfiller",
"publishConfig": {
"access": "public"
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.cjs', '.mjs'];
export const MATCHES_EXTENSION = new RegExp(
`\\.(${EXTENSIONS.map((ext) => ext.substr(1)).join('|')})$`
);
export const MATCHES_GLOB = /\/[*/]+\/?$/;

export const VALID_JSX_OPTIONS: readonly JSX[] = [
'preserve',
Expand Down
21 changes: 15 additions & 6 deletions src/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { EnvironmentPlugin } from 'webpack';
import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import { Command, Mode, WebpackConfigs } from './types';
import { CONFIG_FILE_NAME, EXTENSIONS, MATCHES_EXTENSION } from './constants';
import {
CONFIG_FILE_NAME,
EXTENSIONS,
MATCHES_EXTENSION,
MATCHES_GLOB,
} from './constants';
import { getTsconfig, resolveTsconfigPath } from './tsconfig';
import { getTsbConfig } from './config';
import HtmlWebpackPlugin from 'html-webpack-plugin';
Expand Down Expand Up @@ -93,6 +98,14 @@ export const createWebpackConfig = (
logger.log(`Cleared ${fullOutDir}`);
}

const tsconfigInclude = (tsconfig.include ?? []).map((comp) =>
comp.replace(MATCHES_GLOB, '')
);

const additionalInclude = additionalFilesToParse.map((comp) =>
path.resolve(fullConfigDir, comp)
);

return {
base: {
mode,
Expand All @@ -115,11 +128,7 @@ export const createWebpackConfig = (
rules: [
{
test: MATCHES_EXTENSION,
include: [...(tsconfig.include ?? [])].concat(
[...additionalFilesToParse].map((comp) =>
path.resolve(fullConfigDir, comp)
)
),
include: [...tsconfigInclude, ...additionalInclude],
use: [
{
loader: 'babel-loader',
Expand Down
2 changes: 1 addition & 1 deletion test-files/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"jsx": "react",
"module": "CommonJS"
},
"include": ["src", "tsb.config.ts"]
"include": ["src/**/*", "tsb.config.ts"]
}
2 changes: 1 addition & 1 deletion tsconfig.dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"outDir": "dist",
"module": "CommonJS"
},
"include": ["src"]
"include": ["src/**/*"]
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"moduleResolution": "Node",
"module": "ESNext"
},
"include": ["src", "tests"]
"include": ["src/**/*", "tests/**/*"]
}

0 comments on commit 4263981

Please sign in to comment.