callstack / react-theme-provider

A set of utilities that help you create your own React theming system in few easy steps
MIT License
465 stars 54 forks source link

Error: 'createTheming' is not exported #68

Closed ryanfitzer closed 5 years ago

ryanfitzer commented 5 years ago

Environment

node@12.10.0 @callstack/react-theme-provider@3.0.3 rollup-plugin-babel@4.3.3

Description

When compiling via Rollup, I get the following error:

Error: 'createTheming' is not exported by node_modules/@callstack/react-theme-provider/lib/index.js

I've tried enabling Babel to both ignore and include the node_modules directory.

This runs fine in Storybook (including static build). Not sure what I'm missing.

I see that node_modules/@callstack/react-theme-provider/lib/index.js has the following on line 7:

exports.createTheming = _createTheming.default;

Reproducible Demo

theme.js

import { createTheming } from '@callstack/react-theme-provider';
import tokens from '../../library/styles/tokens';

const { ThemeProvider, withTheme, useTheme } = createTheming( tokens );

export { ThemeProvider, withTheme, useTheme };

example-button.js

import React from 'react';
import { useTheme } from '../theme';

const Button = ( { text, onClick, theme } ) => {

    const tokens = useTheme( theme );

    const styles = {
        fontFamily: tokens.fontBase,
        backgroundColor: tokens.colorLink
    };

    return (
        <button
            type='button'
            onClick={ onClick }
            style={ styles }
        >
            { text }
        </button>
    );

};

export default Button;
ryanfitzer commented 5 years ago

Since my project is creating an esm build and react-theme-provider is provided as a cjs module, I was able to resolve the issue by adding rollup-plugin-commonjs to my rollup.config.js configuration.

Any plans to provide an ECMAScript module version in the future?