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

How to configure rollup without TypeScript? #55

Open
danilosingh opened this issue Jun 16, 2020 · 0 comments
Open

How to configure rollup without TypeScript? #55

danilosingh opened this issue Jun 16, 2020 · 0 comments

Comments

@danilosingh
Copy link

I'm trying to set up the rollup to publish components to NPM, but I'm not getting it.
I found issue #33 and tried to make similar settings, but without TypeScript. The package builds and generates the distribution file, but the error below occurs when starting the test package that references the component within the monorepo.

TypeError: Cannot assign to read only property 'exports' of object '# '

I believe he must be trying to compile what has already been compiled through rollup / babel.

My rollup.config:


import commonjs from 'rollup-plugin-commonjs';
import external from 'rollup-plugin-peer-deps-external';
import postcss from 'rollup-plugin-postcss';
import resolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import nodeBuiltins from 'rollup-plugin-node-builtins';
import url from 'rollup-plugin-url';
import svgr from '@svgr/rollup';

import pkg from './package.json';

export default {
  input: 'index.js',
  output: [
    {
      file: pkg.main,
      format: 'cjs',
      exports: 'named',
      sourcemap: true,
    },
    // Enable to create ES-modules output
    {
      file: pkg.module,
      format: 'es',
      exports: 'named',
      sourcemap: true,
    },
  ],
  plugins: [
    external(), // Set peerDependencies as external
    postcss({
      modules: false,
    }),
    url(),
    svgr(),
    nodeBuiltins({ crypto: false }),
    resolve({
      extensions: ['.mjs', '.js', '.json', '.node'],
      preferBuiltins: true,
    }),
    babel({
      exclude: ['node_modules/**', 'dist/**'],
      presets: ['@babel/env', '@babel/preset-react'],
    }),
    commonjs({
      exclude: 'src/**',
    }),
  ],
};

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

No branches or pull requests

1 participant