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

Inferno-* Packages break on V4 with Webpack 4 #1296

Closed
IgnusG opened this issue Mar 7, 2018 · 8 comments
Closed

Inferno-* Packages break on V4 with Webpack 4 #1296

IgnusG opened this issue Mar 7, 2018 · 8 comments

Comments

@IgnusG
Copy link

IgnusG commented Mar 7, 2018

Observed Behaviour

When using inferno-mobx with inferno 4 and webpack 4 the build fails with the following message:

ERROR in ./node_modules/inferno-mobx/dist/index.mjs
467:2-11 Can't import the named export 'Component' from non EcmaScript module (only default export is available)
 @ ./node_modules/inferno-mobx/dist/index.mjs
 @ ./node_modules/inferno-mobx/index.mjs
 @ ./src/index.jsx

inferno-clone-vnode, inferno-compat, inferno-create-class, inferno-mobx & inferno-router all seem to break with similar errors with either Can't import or Can't reexport.

This only happens when one of these packages is imported inside the code. Check out the master branch for the working code without anything outside of inferno and the broken branch with inferno-mobx in https://github.com/IgnusG/infernoV4-webpackV4-fail

Inferno Metadata
Inferno 4.0.8
Webpack 4.1.0

@jdalton
Copy link

jdalton commented Mar 7, 2018

Adopting .mjs is a bit premature since Node is still ironing out support. This means your code will be feature limited to a narrow path of known behaviors with .mjs in webpack.

Update:

If you use ESM with .js then no type config is needed. It with automatically use javascript/auto and also give you named exports of CJS modules in ESM 🙌

@zenshixd
Copy link

@jdalton so whats the solution to this error ? I am having exactly same problem.
I am not using any .mjs files inside my project.

@jdalton
Copy link

jdalton commented Mar 11, 2018

@Ownelek are you using a package that does use .mjs? If not it could be a webpack bug.

@zenshixd
Copy link

zenshixd commented Mar 11, 2018

@jdalton In my project only Inferno uses .mjs, and with Inferno I have this error.

ERROR in ./node_modules/inferno-create-element/dist/index.mjs
115:15-35 Can't import the named export 'createComponentVNode' from non EcmaScript module (only default export is available)
 @ ./node_modules/inferno-create-element/dist/index.mjs
 @ ./app/client.js

ERROR in ./node_modules/inferno-create-element/dist/index.mjs
117:11-22 Can't import the named export 'createVNode' from non EcmaScript module (only default export is available)
 @ ./node_modules/inferno-create-element/dist/index.mjs
 @ ./app/client.js

ERROR in ./node_modules/inferno-create-element/dist/index.mjs
64:16-39 Can't import the named export 'getFlagsForElementVnode' from non EcmaScript module (only default export is available)
 @ ./node_modules/inferno-create-element/dist/index.mjs
 @ ./app/client.js

Also I am using Typescript in my project, so ./app/client.js is a transpiled version of ./app/client.tsx.

import * as Inferno from "inferno";
import {createElement} from 'inferno-create-element';
import {ChaosHelperView} from "./pages/chaosHelper/ChaosHelperView";

Inferno.render(<ChaosHelperView/>, document.getElementsByTagName('main')[0]);

@IgnusG
Copy link
Author

IgnusG commented Mar 11, 2018

All inferno packages use it I think. I tried patching it by removing the .mjs files from inside node_modules but that results in a lot of other errors

Ultimately this needs to be fixed by inferno as for now this breaks

@Havunen
Copy link
Member

Havunen commented Mar 12, 2018

I will change all file extensions from .mjs to .esm.js that should work without issues. We need to bump version to 5 because its breaking change.

@IgnusG
Copy link
Author

IgnusG commented Mar 12, 2018

Makes me sad for some reason. Was hoping for some big new features in 5 😅
Guess will have to wait for 6

@Havunen
Copy link
Member

Havunen commented Mar 13, 2018

Fix for this has landed to dev 96bc3af
I will close this ticket as it will be fixed in next release. v5

@Havunen Havunen closed this as completed Mar 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants