Skip to content

Commit

Permalink
fix(build): remove "browser" field in package.json
Browse files Browse the repository at this point in the history
There is nothing special in the browser build that is actually practical
for modern use. The "browser" field, as defined in
https://github.com/defunctzombie/package-browser-field-spec#overview,
indicates that you should use it if you are directly accessing globals,
using browser-specific features, dom manipulation, etc.

React components like react-draggable are built to do minimal raw
DOM manipulation, and to always gate this behind conditionals to ensure
that server-side rendering still works. We don't make any changes
to any of that for the "browser" build, so it's entirely redundant.

Hoping this also fixes the "Super expression must either be null or
a function" error (#472) that some users have experienced with particular
bundler configurations.

The browser build may still be imported at "build/web/react-draggable.min.js".
This is to prevent breakage only. The file is no longer minified to prevent
possible [terser bugs](terser/terser#308).
  • Loading branch information
STRML committed May 12, 2020
1 parent 7018422 commit 447df79
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -3,7 +3,6 @@
"version": "4.3.1",
"description": "React draggable component",
"main": "build/cjs/cjs.js",
"browser": "build/web/react-draggable.min.js",
"module": "build/module/Draggable.js",
"scripts": {
"test": "make test",
Expand Down
7 changes: 1 addition & 6 deletions webpack.config.js
@@ -1,6 +1,5 @@
const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');

// Grabbed in .babelrc.js to switch on transpiling modules.
// We want webpack to handle modules if possible.
Expand Down Expand Up @@ -65,10 +64,6 @@ module.exports = (env, argv) => ({
new webpack.optimize.ModuleConcatenationPlugin(),
],
optimization: {
minimizer: [new TerserPlugin({
include: /\.min\.js$/,
sourceMap: true,
terserOptions: {}
})],
minimize: false,
}
});

0 comments on commit 447df79

Please sign in to comment.