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

Fix the rollup-plugin-typescript2 objectHashIgnoreUnknownHack warning #339

Merged
merged 1 commit into from
Apr 28, 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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"resolve-from": "^5.0.0",
"rollup-plugin-typescript2": "^0.19.2",
"semantic-release": "^15.13.3",
"semver": "^7.3.2",
"slash": "^2.0.0",
"string-width": "^3.0.0",
"stringify-author": "^0.1.3",
Expand Down
19 changes: 18 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,23 @@ export class Bundler {
rollupFormat === 'iife' ||
config.bundleNodeModules

// rollup-plugin-typescript2 < v0.26 needs the `objectHashIgnoreUnknownHack`
// option to be enabled to correctly handle async plugins, but it's no
// longer needed (and causes a warning) if the user has a more recent
// version installed. [1] if the plugin is installed, detect the version
// and enable/disable the option accordingly.
//
// [1] https://github.com/egoist/bili/issues/305
const getObjectHashIgnoreUnknownHack = (): boolean => {
try {
const { version } = this.localRequire('rollup-plugin-typescript2/package.json')
const semver = require('semver')
return semver.lt(version, '0.26.0')
} catch (e) {
return true
}
}

const pluginsOptions: { [key: string]: any } = {
progress:
config.plugins.progress !== false &&
Expand Down Expand Up @@ -227,7 +244,7 @@ export class Bundler {
(source.hasTs || config.plugins.typescript2) &&
merge(
{
objectHashIgnoreUnknownHack: true,
objectHashIgnoreUnknownHack: getObjectHashIgnoreUnknownHack(),
tsconfigOverride: {
compilerOptions: {
module: 'esnext'
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8432,6 +8432,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e"
integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==

semver@^7.3.2:
version "7.3.2"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==

semver@~5.3.0:
version "5.3.0"
resolved "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"
Expand Down