Skip to content

Commit

Permalink
Use user's typescript first, fallback to bundled (#741)
Browse files Browse the repository at this point in the history
* use process.cwd()'s typescript

* use process.argv[1]'s instead of process.cwd()'s typescript

* Handle situation that argv1 is empty

* changeset

* Require "typescript" from cwd i.o. argv1
  • Loading branch information
whitetrefoil authored Dec 17, 2020
1 parent 360511b commit 8142704
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-guests-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'microbundle': minor
---

Use user's typescript first, fallback to bundled
9 changes: 8 additions & 1 deletion package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"lodash.merge": "^4.6.2",
"module-details-from-path": "^1.0.3",
"pretty-bytes": "^5.3.0",
"resolve-from": "^4.0.0",
"rollup": "^1.32.1",
"rollup-plugin-bundle-size": "^1.0.1",
"rollup-plugin-es3": "^1.1.0",
Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import autoprefixer from 'autoprefixer';
import cssnano from 'cssnano';
import { rollup, watch } from 'rollup';
import builtinModules from 'builtin-modules';
import resolveFrom from 'resolve-from';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import customBabel from './lib/babel-custom';
Expand Down Expand Up @@ -486,7 +487,10 @@ function createConfig(options, entry, format, writeMeta) {
},
useTypescript &&
typescript({
typescript: require('typescript'),
typescript: require(resolveFrom.silent(
options.cwd,
'typescript',
) || 'typescript'),
cacheRoot: `./node_modules/.cache/.rts2_cache_${format}`,
useTsconfigDeclarationDir: true,
tsconfigDefaults: {
Expand Down

0 comments on commit 8142704

Please sign in to comment.