diff --git a/.changeset/silver-guests-brake.md b/.changeset/silver-guests-brake.md new file mode 100644 index 00000000..9c36939e --- /dev/null +++ b/.changeset/silver-guests-brake.md @@ -0,0 +1,5 @@ +--- +'microbundle': minor +--- + +Use user's typescript first, fallback to bundled diff --git a/package-lock.json b/package-lock.json index 29ff7d3c..e193485a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "microbundle", - "version": "0.12.3", + "version": "0.12.4", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -9228,6 +9228,13 @@ "requires": { "parent-module": "^1.0.0", "resolve-from": "^4.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==" + } } }, "import-from": { diff --git a/package.json b/package.json index 5d4abf3b..1030c659 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.js b/src/index.js index 765bd0eb..599e2a06 100644 --- a/src/index.js +++ b/src/index.js @@ -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'; @@ -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: {