Skip to content

Commit 0bdc106

Browse files
authored
Merge pull request #13 from jayfreestone/modernize-build
Modernize build process and drop UMD/CJS
2 parents 128f845 + 6879407 commit 0bdc106

13 files changed

Lines changed: 2096 additions & 3940 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
node_modules/
33
cypress/videos/
44
dist/*
5-
!dist/.gitkeep

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
# include whitelist
44
!dist/*.js
55
!dist/types/**/*.d.ts
6-
!css/*.css
6+
!dist/*.css

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
14.16.0

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ jobs:
1313
include:
1414
- stage: test
1515
before_script: npm run build
16-
script: npm run test:ci
17-
- before_script: npm run build
18-
script: npm run test:lint
16+
script: npm run test
1917
- before_script: npm run build
2018
script: npx bundlesize
2119
- stage: release

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ There's also a Glitch pen [available here](https://priority-plus-demo.glitch.me/
1515

1616
**The short stuff**:
1717

18-
- Vanilla JS, dependency free. Available as an ES6 module, CJS module, or a UMD bundle.
18+
- Vanilla JS, dependency free. Available as an ES6 module, or a drop-in IIFE assigned to the global `priorityPlus`.
1919
- Uses the [`IntersectionObserver` API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) instead of width-based calculations.
2020
- Toggles the appropriate [WAI-ARIA](https://www.w3.org/WAI/standards-guidelines/aria/) attributes to remain accessible.
2121
- Provides a class hook to style the menu differently when all items are in the overflow/hidden.
@@ -83,9 +83,9 @@ npm install priority-plus
8383
Or use a CDN if you're feeling old-school:
8484

8585
```html
86-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/priority-plus/css/priority-plus.css">
86+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/priority-plus/dist/priority-plus.css">
8787
<!-- Will be available globally as priorityPlus -->
88-
<script defer src="https://cdn.jsdelivr.net/npm/priority-plus/dist/priority-plus.umd.js"></script>
88+
<script defer src="https://cdn.jsdelivr.net/npm/priority-plus/dist/priority-plus.js"></script>
8989
```
9090

9191
## Setup
@@ -106,7 +106,7 @@ You can create a new instance by passing in an `HTMLElement` that is the direct
106106

107107
```css
108108
// Doesn't have to be SASS, just ensure the CSS is included.
109-
@import "node_modules/priority-nav/css/priority-plus";
109+
@import "node_modules/priority-plus/dist/priority-plus";
110110
```
111111

112112
```javascript

cypress.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"baseUrl": "http://127.0.0.1:8080",
2+
"baseUrl": "http://127.0.0.1:8000",
33
"video": false
44
}

dist/.gitkeep

Whitespace-only changes.

package-lock.json

Lines changed: 2043 additions & 3898 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22
"name": "priority-plus",
33
"version": "0.0.0-semantically-released",
44
"description": "A modern implementation of the priority plus navigation pattern.",
5-
"main": "dist/priority-plus.cjs.js",
5+
"type": "module",
66
"module": "dist/priority-plus.esm.js",
7-
"browser": "dist/priority-plus.umd.js",
7+
"browser": "dist/priority-plus.js",
8+
"exports": {
9+
"import": "./dist/priority-plus.esm.js",
10+
"default": "./dist/priority-plus.js"
11+
},
812
"types": "dist/types/priorityPlus.d.ts",
913
"scripts": {
10-
"build": "concurrently \"npm:build:lib\" \"npm:build:types\"",
11-
"build:lib": "rollup -c",
14+
"dev": "esbuild src/browser.ts --bundle --sourcemap --format=iife --servedir=www --outdir=www/assets",
15+
"prebuild": "rimraf dist",
16+
"build": "concurrently \"npm:build:*\"",
17+
"build:esm": "esbuild src/priorityPlus.ts --bundle --minify --format=esm --outfile=dist/priority-plus.esm.js",
18+
"build:iife": "esbuild src/browser.ts --bundle --minify --format=iife --outfile=dist/priority-plus.js",
1219
"build:types": "tsc --emitDeclarationOnly --declarationDir dist/types",
13-
"dev": "rollup -c -w",
14-
"test": "concurrently \"npm:serve\" \"cypress run\"",
15-
"test:ci": "npm run serve & wait-on http://localhost:8080 && cypress run",
20+
"test": "npm run test:types && npm run test:lint && npm run test:e2e",
21+
"test:types": "tsc --noEmit",
1622
"test:lint": "tslint -c tslint.json 'src/**/*.ts'",
17-
"test:open": "concurrently \"npm:serve\" \"cypress open\"",
18-
"serve": "http-server -c-1"
23+
"test:e2e": "npm run dev & wait-on http-get://localhost:8000 && cypress run"
1924
},
2025
"repository": {
2126
"type": "git",
@@ -31,27 +36,24 @@
3136
"url": "https://github.com/jayfreestone/priority-plus/issues"
3237
},
3338
"homepage": "https://github.com/jayfreestone/priority-plus#readme",
34-
"dependencies": {
35-
"@babel/core": "^7.10.4",
36-
"@babel/preset-env": "^7.10.4",
37-
"babel-loader": "^8.1.0"
38-
},
39+
"dependencies": {},
3940
"devDependencies": {
40-
"@cypress/webpack-preprocessor": "^5.4.1",
41-
"@types/chai": "^4.2.11",
42-
"@types/mocha": "^7.0.2",
43-
"concurrently": "^5.2.0",
44-
"cypress": "^4.9.0",
45-
"http-server": "^0.12.3",
46-
"rollup": "^2.18.2",
47-
"rollup-plugin-terser": "^6.1.0",
48-
"rollup-plugin-typescript": "^1.0.1",
49-
"ts-loader": "^7.0.5",
50-
"tslib": "^2.0.0",
41+
"@babel/core": "^7.13.14",
42+
"@babel/preset-env": "^7.13.12",
43+
"@cypress/webpack-preprocessor": "^5.6.0",
44+
"@types/chai": "^4.2.15",
45+
"@types/mocha": "^8.2.2",
46+
"babel-loader": "^8.2.2",
47+
"concurrently": "^6.0.0",
48+
"cypress": "^6.8.0",
49+
"esbuild": "^0.11.2",
50+
"rimraf": "^3.0.2",
51+
"ts-loader": "^8.1.0",
52+
"tslib": "^2.1.0",
5153
"tslint": "^6.1.2",
52-
"typescript": "^3.9.6",
53-
"wait-on": "^5.0.1",
54-
"webpack": "^4.43.0"
54+
"typescript": "^4.2.3",
55+
"wait-on": "^5.3.0",
56+
"webpack": "^5.28.0"
5557
},
5658
"keywords": [
5759
"navigation",
@@ -66,6 +68,7 @@
6668
}
6769
],
6870
"release": {
71+
"branches": ["master"],
6972
"plugins": [
7073
"@semantic-release/commit-analyzer",
7174
"@semantic-release/release-notes-generator",
@@ -74,8 +77,7 @@
7477
"@semantic-release/github",
7578
{
7679
"assets": [
77-
"dist/*.js",
78-
"css/*.css"
80+
"dist/**/*"
7981
]
8082
}
8183
]

0 commit comments

Comments
 (0)