@@ -136,6 +136,23 @@ function assertVersion(range: string | number): void {
136136 // do not want ^7.0.0 to match 8.0.0-alpha.1.
137137 if ( range === "*" || semver . satisfies ( coreVersion , range ) ) return ;
138138
139+ const message =
140+ `Requires Babel "${ range } ", but was loaded with "${ coreVersion } ". ` +
141+ `If you are sure you have a compatible version of @babel/core, ` +
142+ `it is likely that something in your build process is loading the ` +
143+ `wrong version. Inspect the stack trace of this error to look for ` +
144+ `the first entry that doesn't mention "@babel/core" or "babel-core" ` +
145+ `to see what is calling Babel.` ;
146+
147+ if (
148+ typeof process !== "undefined" &&
149+ process . env . BABEL_8_BREAKING &&
150+ process . env . BABEL_7_TO_8_DANGEROUSLY_DISABLE_VERSION_CHECK
151+ ) {
152+ console . warn ( message ) ;
153+ return ;
154+ }
155+
139156 const limit = Error . stackTraceLimit ;
140157
141158 if ( typeof limit === "number" && limit < 25 ) {
@@ -144,14 +161,7 @@ function assertVersion(range: string | number): void {
144161 Error . stackTraceLimit = 25 ;
145162 }
146163
147- const err = new Error (
148- `Requires Babel "${ range } ", but was loaded with "${ coreVersion } ". ` +
149- `If you are sure you have a compatible version of @babel/core, ` +
150- `it is likely that something in your build process is loading the ` +
151- `wrong version. Inspect the stack trace of this error to look for ` +
152- `the first entry that doesn't mention "@babel/core" or "babel-core" ` +
153- `to see what is calling Babel.` ,
154- ) ;
164+ const err = new Error ( message ) ;
155165
156166 if ( typeof limit === "number" ) {
157167 Error . stackTraceLimit = limit ;
0 commit comments