-
Notifications
You must be signed in to change notification settings - Fork 2
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
Using this in create-react-app results in build error #18
Comments
Create React App does not properly support the .mjs extension. I
circumvented this issue in the fontoxpath playground by using customize-cra
to patch in support for .mjs files.
Op do 2 jul. 2020 om 22:02 schreef Wybe <notifications@github.com>:
… For some site I'm using xml-renderer as a client-side transformation from
XML to React component. It depends on fontoxpath ^3.9.2. When
reinstalling this module recently the newest version of fontoxpath, 3.12.0,
was installed which in turn depends on xspattern and whynot beyond that.
This crashed the build system of create-react-app with the following
error:
/Users/wybe/Git/xml-renderer/node_modules/xspattern/dist/xspattern.mjs
Can't import the named export 'compileVM' from non EcmaScript module (only default export is available)
This references the very start of that built file;
import{compileVM as A}from"whynot";function…
Changing that portion to only use the default export fixed the error:
import whynot from "whynot";const A = whynot.compileVM;function…
To reproduce:
- Instantiate a new React project using npx create-react-app test
- cd test && npm install fontoxpath
- Import fontoxpath somewhere, which depends on xspattern
create-react-app version: 3.4.1
xml-renderer version: 3.0.2
fontoxpath version: 3.12.0
xspattern version: 1.2.1
whynot version: 3.0.3
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#18>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGKEJHTXZRXEWC4CXXUDMLRZTRUXANCNFSM4OPGMS5Q>
.
|
For anyone else running into this problem, I've succesfully circumvented this issue in several projects using AKA not using |
Hi Wybe, While I would love for this library to work everywhere with minimal configuration, it seems the story around bundling ESM is currently far from being stabilized. I view renaming the bundle files as a major change, so I'd like to avoid messing around too much to get to a state that works everywhere, let alone have that break again when node, typescript or some bundler change their mind once again. That said, if you have a link to some guide on a setup that works better than what I have currently, please do let me know. For create-react-app in particular, most seem to be of the opinion that this is an issue with that tool, and work-arounds seem to exist (e.g., https://stackoverflow.com/questions/64002604/how-to-make-create-react-app-support-mjs-files-with-webpack). Perhaps that can be of use until the situation around ESM improves? |
I filed this issue to see what the CRA team thinks of this: facebook/create-react-app#10356 |
Thanks @bwrrp @DrRataplan . I agree that the fault is probably with Webpack, not with you. However, that doesn't make a fix any easier for me. I'm currently happy with using an outdated version of If I were to run into an urgent unavoidable reason to upgrade to a newer fontoxpath I will spend time on overriding the webpack config of whatever framework has implemented Webpack (I dont normally configure Webpack myself). The CRA resources you've posted will help, I'm sure some of it carries over to Gatsby etc. too 👍 Thanks! |
I just ran into the same issue for a new app that we are creating. I would be great if we could find a better fix for this. |
As the mjs extension seems to be the main issue here, I'll see if I can experiment a little with whether things work better in most bundlers if both of the bundles use .js instead. |
Results of experimenting, with no or minimal config added for each of these:
Given these results, and despite the weird behavior with linking xspattern in the gatsby app, I'm inclined to try switching all of my libs to the .js extension for now. Installing these libs as a dependency in a CRA or Gatsby app is probably more likely than |
Judging by FontoXML/fontoxpath#286 this has now been resolved, so I'm closing this issue. |
For some site I'm using
xml-renderer
as a client-side transformation from XML to React component. It depends onfontoxpath
^3.9.2
. When reinstalling this module recently the newest version of fontoxpath, 3.12.0, was installed which in turn depends onxspattern
andwhynot
beyond that.This crashed the build system of
create-react-app
with the following error:This references the very start of that built file;
Changing that portion to only use the default export fixed the error and allowed CRA's webpack to continue:
To reproduce:
npx create-react-app test
cd test && npm install fontoxpath
fontoxpath
somewhere, which depends onxspattern
create-react-app
version: 3.4.1xml-renderer
version: 3.0.2fontoxpath
version: 3.12.0xspattern
version: 1.2.1whynot
version: 3.0.3The text was updated successfully, but these errors were encountered: