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

update dependencies #25

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2

[Makefile]
indent_style = tab

[*.py]
indent_style = space
indent_size = 4
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

This repo contains a bare-bones example of how to create an application using Rollup, including importing a module from `node_modules` and converting it from CommonJS.

*See also https://github.com/rollup/rollup-starter-lib*

_See also https://github.com/rollup/rollup-starter-lib_

## Getting started

Expand Down
15 changes: 15 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Node",
"target": "ES2020",
"jsx": "react",
"strictNullChecks": true,
"strictFunctionTypes": true,
"checkJs": true,
},
"exclude": [
"node_modules",
"**/node_modules/*",
]
}
19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
{
"name": "rollup-starter-app",
"version": "0.0.0",
"type": "module",
"devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.1.0",
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.2.1",
"@types/node": "^18.11.17",
"npm-run-all": "^4.1.5",
"rollup": "^2.36.2",
"rollup-plugin-terser": "^7.0.2",
"serve": "^11.3.2"
"prettier": "^2.8.1",
"rollup": "^3.8.1",
"sirv-cli": "^2.0.2"
},
"dependencies": {
"date-fns": "^2.16.1"
"date-fns": "^2.29.3"
},
"scripts": {
"build": "rollup -c",
"watch": "rollup -c -w",
"dev": "npm-run-all --parallel start watch",
"start": "serve public"
"format": "prettier -w .",
"start": "sirv public/ --no-clear"
}
}
39 changes: 20 additions & 19 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head lang='en'>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width'>
<title>rollup-starter-app</title>
<head lang="en">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>rollup-starter-app</title>
<link rel="icon" type="image/svg" href="" />

<style>
body {
font-family: 'Helvetica Neue', Arial, sans-serif;
color: #333;
font-weight: 300;
}
</style>
</head>
<body>
<h1>rollup-starter-app</h1>
<p>The time is <span id='time-now'>...</span></p>
<script src='bundle.js'></script>
</body>
</html>
<style>
body {
font-family: "Helvetica Neue", Arial, sans-serif;
color: #333;
font-weight: 300;
}
</style>
</head>
<body>
<h1>rollup-starter-app</h1>
<p>The time is <span id="time-now">...</span></p>
<script src="bundle.js"></script>
</body>
</html>
31 changes: 17 additions & 14 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import terser from "@rollup/plugin-terser";

// `npm run build` -> `production` is true
// `npm run dev` -> `production` is false
const production = !process.env.ROLLUP_WATCH;

export default {
input: 'src/main.js',
output: {
file: 'public/bundle.js',
format: 'iife', // immediately-invoked function expression — suitable for <script> tags
sourcemap: true
},
plugins: [
resolve(), // tells Rollup how to find date-fns in node_modules
commonjs(), // converts date-fns to ES modules
production && terser() // minify, but only in production
]
input: "src/main.js",
output: {
file: "public/bundle.js",
format: "es", // ESM
sourcemap: true,
},
plugins: [
resolve(), // tells Rollup how to find date-fns in node_modules
commonjs(), // converts date-fns to ES modules
production && terser(), // minify, but only in production
],
watch: {
clearScreen: false,
},
};
8 changes: 5 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import update from './update.js';
import update from "./update.js";

// even though Rollup is bundling all your files together, errors and
// logs will still point to your original source modules
console.log('if you have sourcemaps enabled in your devtools, click on main.js:5 -->');
console.log(
"if you have sourcemaps enabled in your devtools, click on main.js:5 -->"
);

update();
update();
8 changes: 4 additions & 4 deletions src/update.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import format from 'date-fns/format';
import format from "date-fns/format";

var span = document.querySelector('#time-now');
var span = document.querySelector("#time-now");

export default function update() {
span.textContent = format(new Date(), 'h:mm:ssa');
setTimeout(update, 1000);
span.textContent = format(new Date(), "h:mm:ssa");
setTimeout(update, 1000);
}