Skip to content

Commit eaf2582

Browse files
committed
feat: add ESM
BREAKING CHANGE: Updates `scroll-into-view-if-needed` to `v3`
1 parent ff80527 commit eaf2582

File tree

7 files changed

+2115
-1748
lines changed

7 files changed

+2115
-1748
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
node-version: lts/*
9393
- run: npm ci
9494
# Branches that will release new versions are defined in .releaserc.json
95-
- run: semantic-release
95+
- run: npx semantic-release
9696
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
9797
# e.g. git tags were pushed but it exited before `npm publish`
9898
if: always()

package-lock.json

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

package.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,11 @@ import { defineConfig } from '@sanity/pkg-utils'
22

33
export default defineConfig({
44
minify: true,
5+
6+
extract: {
7+
rules: {
8+
'ae-missing-release-tag': 'off',
9+
'ae-forgotten-export': 'off',
10+
},
11+
},
512
})

package.json

Lines changed: 37 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -3,69 +3,58 @@
33
"description": "Ponyfill for smooth scrolling elements into view (if needed!)",
44
"license": "MIT",
55
"author": "Cody Olsen",
6-
"homepage": "https://scroll-into-view-if-needed.netlify.com/",
6+
"homepage": "https://scroll-into-view.dev",
77
"repository": {
88
"type": "git",
9-
"url": "git+https://github.com/stipsan/smooth-scroll-into-view-if-needed.git"
9+
"url": "git+https://github.com/scroll-into-view/smooth-scroll-into-view-if-needed.git"
1010
},
1111
"version": "1.0.1-alpha.3",
12-
"main": "index.js",
13-
"module": "es/index.js",
12+
"type": "module",
13+
"exports": {
14+
".": {
15+
"types": "./dist/index.d.ts",
16+
"source": "./src/index.ts",
17+
"import": "./dist/index.js",
18+
"require": "./dist/index.cjs",
19+
"default": "./dist/index.js"
20+
},
21+
"./package.json": "./package.json"
22+
},
23+
"main": "./dist/index.cjs",
24+
"module": "./dist/index.js",
25+
"typings": "./dist/index.d.ts",
1426
"files": [
15-
"es",
16-
"typings",
17-
"umd"
27+
"dist",
28+
"src"
1829
],
1930
"scripts": {
20-
"prebuild": "yarn clean",
21-
"build": "yarn build:d.ts && yarn build:cjs && yarn build:es && yarn build:umd && yarn build:umd.min",
22-
"build:cjs": "BABEL_ENV=cjs babel src -d . --extensions '.ts'",
23-
"build:d.ts": "tsc --emitDeclarationOnly",
24-
"build:es": "BABEL_ENV=es babel src -d es --extensions '.ts'",
25-
"build:umd": "BABEL_ENV=umd NODE_ENV=development rollup -c -f umd -o umd/smooth-scroll-into-view-if-needed.js",
26-
"build:umd.min": "BABEL_ENV=umd NODE_ENV=production rollup -c -f umd -o umd/smooth-scroll-into-view-if-needed.min.js",
27-
"clean": "rimraf 'umd' 'es' 'typings'",
28-
"precommit": "lint-staged",
29-
"dev": "concurrently 'tsc --noEmit --watch' 'yarn build:cjs --watch' 'yarn build:es --watch' 'yarn build:umd --watch' 'yarn build:umd.min --watch'",
30-
"prepublishOnly": "unset npm_config_cafile && yarn build",
3131
"test": "jest",
32-
"typecheck": "tsc --noEmit"
32+
"typecheck": "tsc --noEmit",
33+
"prebuild": "npm run clean",
34+
"build": "pkg build --strict",
35+
"clean": "npx rimraf 'dist'",
36+
"prepublishOnly": "npm run build"
3337
},
3438
"dependencies": {
35-
"scroll-into-view-if-needed": "^2.2.28"
39+
"scroll-into-view-if-needed": "^3.0.6"
3640
},
3741
"devDependencies": {
38-
"@babel/cli": "7.16.0",
39-
"@babel/core": "7.16.0",
40-
"@babel/plugin-external-helpers": "7.16.0",
41-
"@babel/preset-env": "7.16.0",
42-
"@babel/preset-typescript": "7.16.0",
42+
"@sanity/pkg-utils": "^2.2.8",
4343
"@sanity/semantic-release-preset": "^4.0.0",
44-
"@types/jest": "26.0.24",
45-
"babel-eslint": "10.1.0",
46-
"babel-plugin-add-module-exports": "1.0.4",
47-
"babel-plugin-dev-expression": "0.2.3",
48-
"concurrently": "6.4.0",
49-
"eslint": "7.32.0",
50-
"eslint-config-prettier": "8.3.0",
51-
"eslint-plugin-import": "2.25.3",
52-
"eslint-plugin-react": "7.27.0",
53-
"husky": "5.2.0",
54-
"jest": "26.6.3",
55-
"jest-junit": "12.3.0",
56-
"lint-staged": "10.5.4",
57-
"prettier": "2.4.1",
58-
"prettier-package-json": "2.6.0",
44+
"@types/jest": "^26.0.24",
45+
"babel-eslint": "^10.1.0",
46+
"eslint": "^7.32.0",
47+
"eslint-config-prettier": "^8.3.0",
48+
"eslint-plugin-import": "^2.25.3",
49+
"eslint-plugin-react": "^7.27.0",
50+
"jest": "^26.6.3",
51+
"jest-junit": "^12.3.0",
52+
"prettier": "^2.8.4",
53+
"prettier-package-json": "^2.8.0",
5954
"rimraf": "^3.0.2",
60-
"rollup": "2.60.0",
61-
"rollup-plugin-babel": "4.4.0",
62-
"rollup-plugin-commonjs": "10.1.0",
63-
"rollup-plugin-node-resolve": "5.2.0",
64-
"rollup-plugin-replace": "2.2.0",
65-
"rollup-plugin-terser": "7.0.2",
6655
"semantic-release": "^20.1.1",
67-
"ts-jest": "26.5.6",
68-
"typescript": "4.4.4"
56+
"ts-jest": "^26.5.6",
57+
"typescript": "^4.4.4"
6958
},
7059
"keywords": [
7160
"behavior-smooth",
@@ -116,36 +105,6 @@
116105
]
117106
]
118107
},
119-
"lint-staged": {
120-
"*.js": [
121-
"prettier --write",
122-
"git add"
123-
],
124-
"*.{ts,tsx}": [
125-
"prettier --write",
126-
"git add"
127-
],
128-
"*.json": [
129-
"prettier --write",
130-
"git add"
131-
],
132-
"*.css": [
133-
"prettier --write",
134-
"git add"
135-
],
136-
"*.md": [
137-
"prettier --write",
138-
"git add"
139-
],
140-
"**/package.json": [
141-
"prettier-package-json --write",
142-
"git add"
143-
],
144-
"**/.babelrc": [
145-
"prettier --write",
146-
"git add"
147-
]
148-
},
149108
"prettier": {
150109
"semi": false,
151110
"singleQuote": true,
@@ -159,11 +118,5 @@
159118
}
160119
]
161120
},
162-
"release": {
163-
"prepare": [
164-
"@semantic-release/npm"
165-
]
166-
},
167-
"typings": "typings/index.d.ts",
168121
"sideEffects": false
169122
}

rollup.config.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

tests/scroll.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ test('resolves after scroll is completed', () => {
1010
{ el: { scrollTop: 0, scrollLeft: 0 }, top: 60, left: 60 },
1111
])
1212
)
13-
const scrollIntoView = require('../src').default
13+
const scrollIntoView = require('../src')
1414
expect.assertions(1)
1515
return expect(scrollIntoView(document.body)).resolves.toEqual([
1616
{ el: { scrollTop: 60, scrollLeft: 60 }, top: [0, 60], left: [0, 60] },
@@ -25,7 +25,7 @@ test('resolves right away if there is nothign to scroll', () => {
2525
{ el: { scrollTop: 0, scrollLeft: 0 }, top: 0, left: 0 },
2626
])
2727
)
28-
const scrollIntoView = require('../src').default
28+
const scrollIntoView = require('../src')
2929
expect.assertions(1)
3030
return expect(
3131
scrollIntoView(document.body, { duration: Number.MAX_VALUE })

tsconfig.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
4-
"module": "es2015",
3+
"target": "esnext",
4+
"module": "esnext",
55
"moduleResolution": "node",
6-
"esModuleInterop": true,
76
"declaration": true,
87
"rootDir": "src",
9-
"declarationDir": "typings",
8+
"outDir": "dist",
9+
"declarationDir": "dist",
10+
"emitDeclarationOnly": true,
1011
"noImplicitReturns": true,
1112
"noFallthroughCasesInSwitch": true,
12-
"strictNullChecks": true,
1313
"skipLibCheck": true,
1414
"noUnusedLocals": true,
1515
"noUnusedParameters": true,
1616
"strict": true,
17-
"noImplicitAny": true,
18-
"alwaysStrict": true,
19-
"lib": ["es5", "es2015.promise", "dom"]
17+
"lib": ["dom", "dom.iterable", "esnext"]
2018
},
21-
"exclude": ["tests", "package.config.ts"]
22-
}
19+
"exclude": ["node_modules", "dist", "tests", "package.config.ts"]
20+
}

0 commit comments

Comments
 (0)