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

DEBUG build is not compatible with IE8 #14

Closed
bcowgill opened this issue Mar 29, 2018 · 2 comments
Closed

DEBUG build is not compatible with IE8 #14

bcowgill opened this issue Mar 29, 2018 · 2 comments

Comments

@bcowgill
Copy link

bcowgill commented Mar 29, 2018

First of all, thanks a million for making this IE8 compatible react repository available. We're in route to production and suddenly told that we have to support IE8 because the business hasn't completed it's IE8 decommissioning project on time.

The issue I've noticed is if you do the debug build yarn build:debug then the app fails to load in IE8.
I get Expected Identifier error in vendor bundle

 if (true) {
    var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
===>      Symbol.for &&

And Expected identifier, string or number in main bundle

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
must be the default: obj

I found If I always to the Uglify call then it works...

if (!DEBUG) {
  config.plugins.push(new webpack.optimize.DedupePlugin())
}
// Must always be done or it won't work in IE8
  config.plugins.push(new webpack.optimize.UglifyJsPlugin({
    compress: { warnings: VERBOSE, screw_ie8: false },
    mangle: { screw_ie8: false },
    output: { screw_ie8: false },
  }))
if (!DEBUG) {
  config.plugins.push(new webpack.optimize.AggressiveMergingPlugin())
  config.module.loaders
    .find(x => x.loader === 'babel-loader').query.plugins
    .unshift(
    'transform-react-remove-prop-types',
    'transform-react-constant-elements',
    'transform-react-inline-elements',
    'transform-es3-modules-literals',
    'transform-es3-member-expression-literals',
    'transform-es3-property-literals'
    )
}

I tried changing it so it didn't compress or mangle, but still did the output screw_ie8 but that caused the same problem.

@bcowgill
Copy link
Author

bcowgill commented Mar 29, 2018

I have a fix. Just need to use different options to the Uglify when debugging. Must still compress, but don't mangle and beautify the output again.

// Optimize the bundle in release (production) mode
if (!DEBUG) {
  config.plugins.push(new webpack.optimize.DedupePlugin())
}

// Must always Uglify somehow or it won't work in IE8
const uglyOptions = !DEBUG ? {
  compress: {
    warnings: VERBOSE,
    typeofs: false, // suggested for IE10 or less
    screw_ie8: false
  },
  mangle: { screw_ie8: false },
  output: { screw_ie8: false }
} : {
  mangle: false,
  compress: {
    drop_debugger: false,
/* could set lots more settings false to leave the code as is. */
    typeofs: false, // suggested for IE10 or less
    warnings: VERBOSE,
    screw_ie8: false
  },
  output: {
    beautify: true,
    comments: true,
    bracketize: true,
    indent_level: 2,
    keep_quoted_props: true,
/* more settings to your liking... */
    screw_ie8: false
  },
};
config.plugins.push(new webpack.optimize.UglifyJsPlugin(uglyOptions))

if (!DEBUG) {
  config.plugins.push(new webpack.optimize.AggressiveMergingPlugin())
  config.module.loaders
    .find(x => x.loader === 'babel-loader').query.plugins
    .unshift(
    'transform-react-remove-prop-types',
    'transform-react-constant-elements',
    'transform-react-inline-elements',
    'transform-es3-modules-literals',
    'transform-es3-member-expression-literals',
    'transform-es3-property-literals'
    )
}

@copilot-is
Copy link
Owner

Thank you.
Fix 4c38aef

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

2 participants