Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transpileOnly support for TS projects if needed #497

Merged
merged 2 commits into from
Jan 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Options:
-e, --external [mod] Skip bundling 'mod'. Can be used many times
-q, --quiet Disable build summaries / non-error outputs
-w, --watch Start a watched build
-t, --transpile-only Use transpileOnly option with the ts-loader
--v8-cache Emit a build using the v8 compile cache
`;

Expand Down Expand Up @@ -135,7 +136,9 @@ async function runCmd (argv, stdout, stderr) {
"-q": "--quiet",
"--watch": Boolean,
"-w": "--watch",
"--v8-cache": Boolean
"--v8-cache": Boolean,
"--transpile-only": Boolean,
"-t": "--transpile-only",
}, {
permissive: false,
argv
Expand Down Expand Up @@ -223,6 +226,7 @@ async function runCmd (argv, stdout, stderr) {
cache: args["--no-cache"] ? false : undefined,
watch: args["--watch"],
v8cache: args["--v8-cache"],
transpileOnly: args["--transpile-only"],
quiet
}
);
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ module.exports = (
v8cache = false,
filterAssetBase = process.cwd(),
quiet = false,
debugLog = false
debugLog = false,
transpileOnly = false
} = {}
) => {
if (!quiet) {
Expand Down Expand Up @@ -177,6 +178,7 @@ module.exports = (
{
loader: eval('__dirname + "/loaders/ts-loader.js"'),
options: {
transpileOnly,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, we just need a test for this new behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@styfle sure thing. Done.

compiler: eval('__dirname + "/typescript.js"'),
compilerOptions: {
outDir: '//',
Expand Down
4 changes: 4 additions & 0 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,9 @@
expect (code, stdout, stderr) {
return code === 1 && stderr.toString().indexOf('ts-error.ts(3,16)') !== -1 && stderr.toString().split('\n').length < 10;
}
},
{
args: ["run", "-t", "test/fixtures/with-type-errors/ts-error.ts"],
expect: { code: 0 }
}
]
5 changes: 5 additions & 0 deletions test/fixtures/with-type-errors/ts-error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require.extensions['.asdf'] = function () {};

function p (x: Y) {

}
5 changes: 5 additions & 0 deletions test/fixtures/with-type-errors/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"target": "es2015"
}
}