Skip to content

Instantly share code, notes, and snippets.

@ajkovar
Last active September 3, 2020 14:38
Show Gist options
  • Save ajkovar/6538137b9e5d4d371cb5acbe7f65a121 to your computer and use it in GitHub Desktop.
Save ajkovar/6538137b9e5d4d371cb5acbe7f65a121 to your computer and use it in GitHub Desktop.

Currently getting this while intending to use babel plugin for format.js:

Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.
at throwVersionError (/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/helper-plugin-utils/lib/index.js:65:11)
at Object.assertVersion (/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/helper-plugin-utils/lib/index.js:13:11)
at /Users/alex/projects/you/YOU-Frontend/node_modules/babel-plugin-react-intl/src/index.ts:302:7
at /Users/alex/projects/you/YOU-Frontend/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12

Problematic line:

https://github.com/formatjs/formatjs/blob/main/packages/babel-plugin-react-intl/index.ts#L359

Move to use babel 7 APIs happened on June 17

https://github.com/formatjs/formatjs/commit/f473f607965ebb65a4ae0c24807f58518eabe62e#diff-ff8aba3b85de888385a9fb4cad2750d7R321

Attemps to use version older of babel-plugin-react-intl either still require 7:

https://www.npmjs.com/package/babel-plugin-react-intl/v/4.0.0

4.0 was published a year ago according to npm. Even older versions, e.g.:

https://www.npmjs.com/package/babel-plugin-react-intl/v/3.0.0

just don't work at all. Giving this error on page load:

utils.js?73c2:76 Uncaught Error: [@formatjs/intl] An `id` must be provided to format a message.
at invariant (utils.js?73c2:76)
at formatMessage (message.js?ab38:41)
at formatMessage (provider.js?90d5:76)
at eval (message.js?7c48:60)

Docs on npm for 3.0 are quite a bit different. It seems that the repo was moved. Here was the original location (with some docs for that version):

https://github.com/formatjs/babel-plugin-react-intl

Attempting to upgrade babel so far was not much more successful. It involved upgrading a ton of libraries that depend on babel-core. Not only that but this is where babel makes it's jump to the @babel/ format so the packages must all be replaced by their new scoped equivalent. I have my current attempt in a branch but it is currently stuck on this error:

/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/core/lib/config/files/plugins.js:152
throw e;
^

Error: Cannot find module 'babel-plugin-syntax-decorators' from '/Users/alex/projects/you/YOU-Frontend'
- Did you mean "@babel/syntax-decorators"?
at Function.resolveSync [as sync] (/Users/alex/projects/you/YOU-Frontend/node_modules/resolve/lib/sync.js:89:15)
at resolveStandardizedName (/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/core/lib/config/files/plugins.js:101:31)
at resolvePlugin (/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/core/lib/config/files/plugins.js:54:10)
at loadPlugin (/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/core/lib/config/files/plugins.js:62:20)
at createDescriptor (/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/core/lib/config/config-descriptors.js:154:9)
at items.map (/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/core/lib/config/config-descriptors.js:109:50)

Which arose after upgrading babel-plugin-syntax-decorators (previously this error):

/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/core/lib/parser/index.js:95
throw err;
^

Error: The 'decorators' plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean. If you are migrating from Babylon/Babel 6 or want to use the old decorators proposal, you should use the 'decorators-legacy' plugin instead of 'decorators'.
at validatePlugins (/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/parser/lib/index.js:7489:13)
at getParser (/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/parser/lib/index.js:13115:5)
at parse (/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/parser/lib/index.js:13098:12)
at parser (/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/core/lib/parser/index.js:54:34)
at parser.next (<anonymous>)
at normalizeFile (/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/core/lib/transformation/normalize-file.js:99:38)
at normalizeFile.next (<anonymous>)
at run (/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/core/lib/transformation/index.js:31:50)
at run.next (<anonymous>)
at Function.transform (/Users/alex/projects/you/YOU-Frontend/node_modules/@babel/core/lib/transform.js:27:41)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment