Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

@pika/plugin-bundle-web errors when importing react #34

Open
johndevor opened this issue Apr 8, 2019 · 1 comment
Open

@pika/plugin-bundle-web errors when importing react #34

johndevor opened this issue Apr 8, 2019 · 1 comment

Comments

@johndevor
Copy link

johndevor commented Apr 8, 2019

[5/6] Running @pika/plugin-bundle-web...
Error: 'createContext' is not exported by node_modules/react/index.js
    at error (/Users/john/Desktop/hallway/client/apps/packages/@hallway/windows/node_modules/rollup/dist/rollup.js:3598:30)

Looks like the plugin-bundle-web is unable to bundle the react library into the bundle output, presumably because it is not an ESM module? Is this correct? And is there any way to bundle non-ESM modules into my outputted web bundle?

@johndevor johndevor changed the title @pika/plugin-bundle-web error when importing react @pika/plugin-bundle-web errors when importing react Apr 8, 2019
@FredKSchott
Copy link
Owner

That's actually not expected. You can see us using the Common.js rollup plugin here: https://github.com/pikapkg/builders/blob/master/packages/plugin-bundle-web/src/index.ts#L31

The plugin may treating all CJS as a default export, meaning that you need to do import React from 'react'; and then call React.createContext instead.

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

2 participants