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

change: use peerDeps for typescript, tslib #985

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@
"semver": "^7.1.1",
"shelljs": "^0.8.3",
"tiny-glob": "^0.2.6",
"ts-jest": "^25.3.1",
"tslib": "^1.9.3",
"typescript": "^3.7.3"
"ts-jest": "^25.3.1"
},
"devDependencies": {
"@types/eslint": "^6.1.2",
Expand All @@ -123,8 +121,14 @@
"styled-components": "^5.0.1",
"tiny-invariant": "^1.1.0",
"tiny-warning": "^1.0.3",
"tslib": "^1.9.3",
"typescript": "^3.7.3",
"yarn-deduplicate": "^2.1.1"
},
"peerDependencies": {
"tslib": "^1.9.3 || ^2.0.0",
"typescript": "^3.7.3 || ^4.0.0"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged --pattern '!test/tests/lint/**' && yarn lint && yarn deduplicate:check && doctoc README.md"
Expand All @@ -136,4 +140,4 @@
"singleQuote": true,
"trailingComma": "es5"
}
}
}
17 changes: 16 additions & 1 deletion src/createRollupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import resolve, {
} from '@rollup/plugin-node-resolve';
import sourceMaps from 'rollup-plugin-sourcemaps';
import typescript from 'rollup-plugin-typescript2';
import ts from 'typescript';

import { extractErrors } from './errors/extractErrors';
import { babelPluginTsdx } from './babelPluginTsdx';
Expand All @@ -23,6 +22,22 @@ const errorCodeOpts = {

// shebang cache map thing because the transform only gets run once
let shebang: any = {};
let ts: typeof import('typescript');
try {
ts = require('typescript');
} catch (error) {
throw new Error(
`The module "typescript" was not found. tsdx requires that you include it in "dependencies" of your "package.json". To add it, run "npm install typescript"`
);
}

try {
require.resolve('tslib');
} catch (error) {
console.warn(
`The module "tslib" was not found. We use it to reduce your bundle size.`
);
}

export async function createRollupConfig(
opts: TsdxOptions,
Expand Down