Skip to content

Rollup build breaks in IE11 #214

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

Closed
apolio opened this issue Jan 27, 2021 · 2 comments · Fixed by #216
Closed

Rollup build breaks in IE11 #214

apolio opened this issue Jan 27, 2021 · 2 comments · Fixed by #216
Assignees
Labels
bug Something isn't working

Comments

@apolio
Copy link

apolio commented Jan 27, 2021

Expected Behavior

There should be es5 code only in production build.

Actual Behavior

Similar to 213, there is ES6 code introduced and it breaks the build in IE11.

Configuration

This happens only when building the project in rollup. It doesn't happen for example in Storybook.

See below rollup.config.js

import typescript from 'rollup-plugin-typescript2';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import analyze from 'rollup-plugin-analyzer';
import postcss from 'rollup-plugin-postcss';
import replace from '@rollup/plugin-replace';

export default {
  input: 'src/index.ts',
  output: [
    {
      dir: './lib',
      format: 'es',
    },
    { dir: './commonjs', format: 'cjs' },
  ],
  // this specifies which libraries we do NOT want to bundle as they are peer dependencies
  external: ['react', 'react-dom', 'moment', 'styled-components'],
  // This preserve src/ file structure and separated components
  preserveModules: true,
  plugins: [
    replace({
      // This environment variable is used to add an specific extension to the
      // dynamic import of icons, this should only be present on the final builds
      // for external consumption.
      'process.env.ICON_EXTENSION': JSON.stringify('.js'),
      'process.env.NODE_ENV': JSON.stringify('production'),
    }),
    postcss({
      minimize: true,
    }),
    // resolves node modules and add them into the bundle
    resolve({
      browser: true,
      preferBuiltins: false,
    }),
    typescript({
      useTsconfigDeclarationDir: true,
    }),
    // required to compile external npm packages bundled using cjs modules (rollup and webpack require ESM modules to process a bundle)
    commonjs({
      exclude: ['react', 'react-dom', 'moment', 'styled-components'],
      namedExports: {
        'node_modules/react-dates/index.js': [
          'DayPickerRangeController',
          'CalendarInfoPositionShape',
          'DateRangePicker',
          'SingleDatePicker',
        ],
        'node_modules/xss/lib/index.js': ['DEFAULT', 'whiteList'],
        'node_modules/domhandler/lib/index.js': ['Element'],
      },
    }),
    // uglify and minification of bundle
    terser(),
    // create a report in the console for bundle size and tree shaking
    analyze({
      // summaryOnly: true,
      limit: 0, // to avoid console spam of multiple files
    }),
  ],
};

Following the suggestion in #213 for webpack, I tried introducing this equivalent config in rollup.

By default it has the value ['module', 'main'], so I added

mainFields: ['main', 'module']

It still didn't work. I tried also downgrading to 1.2.0. Although Storybook worked fine with 1.2.0 (including in IE11), the rollup build could not be done successfully. It would fail due to missing packages.

Environment

  • Version: 1.2.1
  • Platform: Build on Rollup
  • Browser: IE11
@remarkablemark
Copy link
Owner

Thanks for opening this issue @apolio.

I can confirm this bug, which was introduced in #210. I will work on a fix.

@remarkablemark
Copy link
Owner

remarkablemark commented Jan 28, 2021

Published v1.2.3:

npm:

npm i html-react-parser@1.2.3

Yarn:

yarn add html-react-parser@1.2.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants