Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for the experimental syntax 'dynamicImport' isn't currently enabled #987

Closed
stereobooster opened this issue May 15, 2018 · 12 comments

Comments

@stereobooster
Copy link

Current behavior

styleguidist server
./node_modules/react-styleguidist/lib/rsg-components/Editor/EditorLoader.js
Syntax error: async-precious/node_modules/react-styleguidist/lib/rsg-components/Editor/EditorLoader.js: Support for the experimental syntax 'dynamicImport' isn't currently enabled (36:4):

  34 | 			var _this2 = this;
  35 |
> 36 | 			import('rsg-components/Editor/Editor').then(function (module) {
     | 			^
  37 | 				_this2.setState({ editor: module.default });
  38 | 			});
  39 | 		}

Add @babel/plugin-syntax-dynamic-import (https://git.io/vb4Sv) to the 'plugins' section of your Babel config to enable parsing.
	from thread-loader (worker 0)

To reproduce

git clone https://github.com/stereobooster/async-precious.git
cd async-precious
git checkout styleguidist-bug
yarn
yarn styleguide

Demo is not based on template, but I guess this doesn't matter because issue is with react-scripts@next.

Issue happens with [email protected] and [email protected].

But not with [email protected] and [email protected].

Expected behavior

No error

@sapegin
Copy link
Member

sapegin commented May 16, 2018

I'm wondering why are they enabling Babel inside node_modules.

@stereobooster
Copy link
Author

Here is proposal for it facebook/create-react-app#3776

@sapegin
Copy link
Member

sapegin commented May 16, 2018

I think we should open an issue there, because they say “Verify this doesn't break third-party code” — but it breaks ;-) And they don't have to compile imports, just allow the syntax. Would you mind opening an issue at create-react-app?

@stereobooster
Copy link
Author

stereobooster commented May 16, 2018

Yes will open. Thanks for the tip

@jmlivingston
Copy link

For what it's worth, I was able to successfully get this running by installing plugin-syntax-dynamic-import then add a .babelrc using create-react-app and react-scripts version 1.1.4. I'm sure mileage will vary.

npm install @babel/plugin-syntax-dynamic-import

.babelrc

{
  "plugins": ["@babel/plugin-syntax-dynamic-import"]
}

@stereobooster
Copy link
Author

stereobooster commented May 17, 2018

create-react-app bug report confirmed. Will close this

UPD: it is confirmed by not maintainer (facepalm). Why would you write "bug confirmed", if you are not maintainer, but whatever

@jmlivingston
Copy link

Yeah, probably should have made that more clear. Maybe "successfully duplicated" would have been more clear? 🤷‍♂️

@stereobooster
Copy link
Author

@sapegin can you please take a part in the discussion in create-react-app 🙌. They try to understand if it is easier drop dynamic import in styleguidist or allow it in node_modules. facebook/create-react-app#3776

Thanks

@stereobooster stereobooster reopened this May 18, 2018
@sapegin
Copy link
Member

sapegin commented May 18, 2018

I don't see any discussion there, is that the right link?

@stereobooster
Copy link
Author

Oh sorry, I meant facebook/create-react-app#4477 (comment)

@sapegin
Copy link
Member

sapegin commented Jul 19, 2018

This may be a good solution for that: #1054.

sapegin added a commit that referenced this issue Aug 5, 2018
BREAKING CHANGE:

* editorConfig option is no longer available
* Remove code splitting and Bable dynamic import plugins

Closes #987 #1054
sapegin added a commit that referenced this issue Aug 6, 2018
BREAKING CHANGE:

* editorConfig option is no longer available
* Remove code splitting and Bable dynamic import plugins

Closes #987 #1054
@sapegin sapegin added this to the 8.0.0: New editor milestone Aug 7, 2018
@sapegin sapegin removed this from the 9.0.0: New editor milestone Nov 3, 2018
@sapegin
Copy link
Member

sapegin commented Nov 3, 2018

This was fixed on CRA side, closing.

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

Successfully merging a pull request may close this issue.

3 participants