Skip to content

Commit

Permalink
Save bundled code to file
Browse files Browse the repository at this point in the history
  • Loading branch information
gdbroman committed Jan 26, 2023
1 parent 59cf62e commit 43543c6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
yarn-error.log
bundle.js
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## bundler
# bundler

A home-made bundler for JavaScript. Inspired by Ronen Amiel's talk [Build Your Own Webpack](https://www.youtube.com/watch?v=Gc9-7PBqOC8).

## Try it

```bash
yarn
yarn build // Run the bundler
yarn start // Run the bundled code
```
3 changes: 2 additions & 1 deletion bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,5 @@ function bundle(graph) {
const graph = creaateGraph("./example/entry.js");
const result = bundle(graph);

console.log(result);
// Save result to file.
fs.writeFileSync("./bundle.js", result);
2 changes: 1 addition & 1 deletion example/name.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const name = "Big Chungus";
export const name = "Hacker";
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"prettier": "^2.8.3"
},
"scripts": {
"bundle": "node ./bundler.js",
"build": "node ./bundler.js",
"start": "node ./bundle.js",
"lint": "eslint . --ext .js --ignore-path .gitignore"
}
}

0 comments on commit 43543c6

Please sign in to comment.