diff --git a/examples/tree-shaking-create-react-app/README.md b/examples/tree-shaking-create-react-app/README.md index 4788aba38..1ca4b8d03 100644 --- a/examples/tree-shaking-create-react-app/README.md +++ b/examples/tree-shaking-create-react-app/README.md @@ -1,23 +1,3 @@ ## Tree shaking for create react app -This is example of `tree-shaking` for [create-react-app](https://github.com/facebook/create-react-app). -By default, we do not `eject` configs from `create-react-app`, in this example, -we use [react-app-rewired](https://github.com/timarney/react-app-rewired) to change the default configs. - -### About - -- Add `config-overrides.js` to your root folder. -- Add deps: `yarn add babel-plugin-import customize-cra react-app-rewired -D` -- Replace your default scripts(`react-scripts`) with `react-app-rewired`. - -### Previews - -**Before:** - -![before](public/esm-1.png) - -
- -**After:** - -![after](public/esm-2.png) +Full tree-shaking is automatically available without any configuration when using `react-scripts 5.0.0` or higher. (`webpack > 5.0`) diff --git a/examples/tree-shaking-create-react-app/build/asset-manifest.json b/examples/tree-shaking-create-react-app/build/asset-manifest.json new file mode 100644 index 000000000..c592b8357 --- /dev/null +++ b/examples/tree-shaking-create-react-app/build/asset-manifest.json @@ -0,0 +1,10 @@ +{ + "files": { + "main.js": "/static/js/main.c0df7028.js", + "index.html": "/index.html", + "main.c0df7028.js.map": "/static/js/main.c0df7028.js.map" + }, + "entrypoints": [ + "static/js/main.c0df7028.js" + ] +} \ No newline at end of file diff --git a/examples/tree-shaking-create-react-app/public/esm-1.png b/examples/tree-shaking-create-react-app/build/esm-1.png similarity index 100% rename from examples/tree-shaking-create-react-app/public/esm-1.png rename to examples/tree-shaking-create-react-app/build/esm-1.png diff --git a/examples/tree-shaking-create-react-app/public/esm-2.png b/examples/tree-shaking-create-react-app/build/esm-2.png similarity index 100% rename from examples/tree-shaking-create-react-app/public/esm-2.png rename to examples/tree-shaking-create-react-app/build/esm-2.png diff --git a/examples/tree-shaking-create-react-app/build/index.html b/examples/tree-shaking-create-react-app/build/index.html new file mode 100644 index 000000000..bdb9ec052 --- /dev/null +++ b/examples/tree-shaking-create-react-app/build/index.html @@ -0,0 +1 @@ +Tree Shaking
\ No newline at end of file diff --git a/examples/tree-shaking-create-react-app/build/static/js/main.c0df7028.js b/examples/tree-shaking-create-react-app/build/static/js/main.c0df7028.js new file mode 100644 index 000000000..0fb745088 --- /dev/null +++ b/examples/tree-shaking-create-react-app/build/static/js/main.c0df7028.js @@ -0,0 +1,3 @@ +/*! For license information please see main.c0df7028.js.LICENSE.txt */ +!function(){"use strict";var e={725:function(e){var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;function a(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(a){return!1}}()?Object.assign:function(e,o){for(var l,i,u=a(e),c=1;c