Flow: "unexpected token import" on dynamic import

Created on 11 Jul 2017  路  9Comments  路  Source: facebook/flow

Seems like dynamic imports should work since https://github.com/facebook/flow/pull/3544.

So I must be doing something wrong in my first dynamic import here:

// @flow
import Loadable from 'react-loadable'

import LoadingComponent from './LoadingComponent'

const AsyncActors = Loadable({
  loader: () => import('./Actors'),
  loading: LoadingComponent,
})

export default AsyncActors

This code provokes "unexpected token import" on the import statement.

I am using flow-bin v0.49.1.

Most helpful comment

I use babel-plugin-dynamic-import-node for jest babel config and babel-plugin-syntax-dynamic-import for webpack. That helps.

All 9 comments

This still happens with flow-bin v0.53.1

I use babel-plugin-dynamic-import-node for jest babel config and babel-plugin-syntax-dynamic-import for webpack. That helps.

Thanks. But I don't want to eject from create-react-app.

I'm getting the same issue with dynamic imports, despite using the babel plugins. Is this being looked into?

@joaquindk Is the problem with flow or babel?

Definitely flow @TrySound

Nice! Thanks @TrySound

This probably can be closed.
/cc @vkurchatkin

Was this page helpful?
0 / 5 - 0 ratings