Skip to content

How to configure rollup without TypeScript? #55

Open
@danilosingh

Description

@danilosingh

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/**',
    }),
  ],
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions