Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

UnhandledPromiseRejectionWarning: Error: You have declared using "bundled" babelHelpers #43

Open
ivandotv opened this issue Sep 19, 2020 · 5 comments

Comments

@ivandotv
Copy link

I'm using nextjs framework, and this is the error that I get when trying to generate the code.

UnhandledPromiseRejectionWarning: Error: You have declared using "bundled" babelHelpers, but transforming /home/user/path.to.machine/file.ts resulted in "runtime". Please check your configuration.

packages:
xstate-codegen@0.1.3
next@9.5.3
xstate@4.13.0

@mattpocock
Copy link
Owner

Thanks for this @ivandotv

This is another error caused by bundling, that will be fixed when we move to a TS-only extraction process in this PR: #29

That PR is our top priority right now - we're testing it this week.

See comments in other issues: #21 and #23.

But let's try to find a workaround. Do you have a babel.config.js knocking about?

@ivandotv
Copy link
Author

Actually I do ( I should have mentioned that earlier)

const pkg = require('./package.json')
const childProcess = require('child_process')
const pkgVersion = `${
  process.env.PKG_VERSION || pkg.version
}-${childProcess.execSync('git rev-parse --short HEAD')}`

module.exports = {
  presets: ['next/babel'],
  plugins: [
    ['inline-react-svg'],
    [
      'transform-define',
      {
        __VERSION__: pkgVersion,
        __DEV__: process.env.NODE_ENV !== 'production'
      }
    ]
  ]
}

This is on top of nextjs babel config.
https://nextjs.org/docs/advanced-features/customizing-babel-config

@mattpocock
Copy link
Owner

Our current rollup-based machine extractor sometimes reads from babel.config.js, so playing with commenting out things in your config may yield some results. Obviously, that may not be a sufficient workaround.

If you can't find a workaround here, it might be worth waiting until #29 is in. We'll be releasing it on a @next branch and I'll make sure to notify you.

@ivandotv
Copy link
Author

ivandotv commented Sep 19, 2020

I can't mess around with the next/babel preset. I will wait for the @next release.
Using Typescript with xstate is such a pain.
Thank you for a prompt reply.

@borispinus
Copy link

borispinus commented Feb 4, 2021

in my case the problem was conflict between @babel/transform-runtime(in my project) and @rollup/plugin-babel(in xstate-codegen)

i'm using webpack for app bundling, so the solution was not to use @babel/transform-runtime during xstate-codegen processing

in my .babelrc.js

if (process.title === "webpack") {
  plugins.push("@babel/transform-runtime");
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants