File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9898 "resolve-from" : " ^5.0.0" ,
9999 "rollup-plugin-typescript2" : " ^0.19.2" ,
100100 "semantic-release" : " ^15.13.3" ,
101+ "semver" : " ^7.3.2" ,
101102 "slash" : " ^2.0.0" ,
102103 "string-width" : " ^3.0.0" ,
103104 "stringify-author" : " ^0.1.3" ,
Original file line number Diff line number Diff line change @@ -177,6 +177,23 @@ export class Bundler {
177177 rollupFormat === 'iife' ||
178178 config . bundleNodeModules
179179
180+ // rollup-plugin-typescript2 < v0.26 needs the `objectHashIgnoreUnknownHack`
181+ // option to be enabled to correctly handle async plugins, but it's no
182+ // longer needed (and causes a warning) if the user has a more recent
183+ // version installed. [1] if the plugin is installed, detect the version
184+ // and enable/disable the option accordingly.
185+ //
186+ // [1] https://github.com/egoist/bili/issues/305
187+ const getObjectHashIgnoreUnknownHack = ( ) : boolean => {
188+ try {
189+ const { version } = this . localRequire ( 'rollup-plugin-typescript2/package.json' )
190+ const semver = require ( 'semver' )
191+ return semver . lt ( version , '0.26.0' )
192+ } catch ( e ) {
193+ return true
194+ }
195+ }
196+
180197 const pluginsOptions : { [ key : string ] : any } = {
181198 progress :
182199 config . plugins . progress !== false &&
@@ -227,7 +244,7 @@ export class Bundler {
227244 ( source . hasTs || config . plugins . typescript2 ) &&
228245 merge (
229246 {
230- objectHashIgnoreUnknownHack : true ,
247+ objectHashIgnoreUnknownHack : getObjectHashIgnoreUnknownHack ( ) ,
231248 tsconfigOverride : {
232249 compilerOptions : {
233250 module : 'esnext'
Original file line number Diff line number Diff line change @@ -8437,6 +8437,11 @@ semver@7.0.0:
84378437 resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e"
84388438 integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==
84398439
8440+ semver@^7.3.2 :
8441+ version "7.3.2"
8442+ resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
8443+ integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==
8444+
84408445semver@~5.3.0 :
84418446 version "5.3.0"
84428447 resolved "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"
You can’t perform that action at this time.
0 commit comments