Skip to content

Commit

Permalink
Merge pull request #498 from Esri/rollup-tree-shaking
Browse files Browse the repository at this point in the history
Rollup treeshaking and tslib
  • Loading branch information
patrickarlt committed Mar 29, 2019
2 parents 6bd5557 + 6ec7ca3 commit f9ad63d
Show file tree
Hide file tree
Showing 20 changed files with 2,398 additions and 137 deletions.
3 changes: 3 additions & 0 deletions demos/tree-shaking-rollup/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [["@babel/env", { "modules": false }]]
}
9 changes: 9 additions & 0 deletions demos/tree-shaking-rollup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Running this demo

This demo shows how to have rollup [tree shake](https://rollupjs.org/guide/en#tree-shaking) `@esri/rest-js` and only include methods that are actually being called in its output bundle.

1. Make sure you run `npm run bootstrap` in the root folder to setup the dependencies
1. cd into `/demos/tree-shaking-rollup/`
1. Run `npm run build`


File renamed without changes.
2,225 changes: 2,225 additions & 0 deletions demos/tree-shaking-rollup/package-lock.json

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions demos/tree-shaking-rollup/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@esri/arcgis-rest-tree-shaking-rollup",
"version": "1.19.0",
"private": true,
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rollup -c"
},
"keywords": [],
"author": "",
"license": "Apache-2.0",
"devDependencies": {
"@babel/core": "^7.4.0",
"@babel/preset-env": "^7.4.2",
"babel-loader": "^8.0.5",
"rollup": "^1.7.4",
"rollup-plugin-node-resolve": "^4.0.1",
"rollup-plugin-babel": "^4.3.2"
},
"dependencies": {
"@esri/arcgis-rest-items": "^1.19.0",
"@esri/arcgis-rest-request": "^1.19.0"
}
}
17 changes: 17 additions & 0 deletions demos/tree-shaking-rollup/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// rollup.config.js
import resolve from "rollup-plugin-node-resolve";
import babel from "rollup-plugin-babel";

export default {
input: "src/index.js",
output: {
file: "dist/bundle.js",
format: "iife"
},
plugins: [
resolve(),
babel({
exclude: "node_modules/**" // only transpile our source code
})
]
};
8 changes: 8 additions & 0 deletions demos/tree-shaking-rollup/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { searchItems } from "@esri/arcgis-rest-items";

let element = document.createElement("div");
document.body.appendChild(element);

searchItems("water").then(response => {
element.innerHTML = JSON.stringify(response); // false
});
9 changes: 9 additions & 0 deletions demos/tree-shaking-webpack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Running this demo

This demo shows how to have webpack [tree shake](https://rollupjs.org/guide/en#tree-shaking) `@esri/rest-js` and only include methods that are actually being called in its output bundle.

1. Make sure you run `npm run bootstrap` in the root folder to setup the dependencies
1. cd into `/demos/tree-shaking-webpack/`
1. Run `npm run build`


11 changes: 11 additions & 0 deletions demos/tree-shaking-webpack/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>shaking the tree</title>
</head>
<body>
<script src="dist/bundle.js"></script>
</body>
</html>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@esri/arcgis-rest-webpack-demo",
"name": "@esri/arcgis-rest-tree-shaking-webpack",
"version": "1.19.0",
"private": true,
"description": "",
Expand Down
File renamed without changes.
File renamed without changes.
11 changes: 0 additions & 11 deletions demos/tree-shaking/README.md

This file was deleted.

41 changes: 30 additions & 11 deletions demos/vue/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f9ad63d

Please sign in to comment.