Skip to content

Commit 46b2cd0

Browse files
authored
feat: moves to esm (#17)
1 parent 2e9d084 commit 46b2cd0

21 files changed

+2989
-2221
lines changed
File renamed without changes.

demo/App.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import React from 'react';
2-
import {
3-
ScrollInfoProvider,
4-
// ScrollInfo,
5-
} from '../src'; // swap '../src' for '../dist/build.bundle' to demo production build
2+
import { ScrollInfoProvider } from '@faceless-ui/scroll-info';
63
// import WithScrollInfo from './WithScrollInfo.demo';
74
import UseScrollInfo from './UseScrollInfo.demo';
85
// import LogProps from './LogProps';

demo/LogProps.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { IScrollInfoContext } from '../src/ScrollInfoProvider/context';
2+
import type { IScrollInfoContext } from '../src/types';
33

44
const filterObject = () => {
55
const seen = new WeakSet();

demo/UseScrollInfo.demo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useScrollInfo } from '../src'; // swap '../src' for '../dist/build.bundle' to demo production build
1+
import { useScrollInfo } from '@faceless-ui/scroll-info';
22
import LogProps from './LogProps';
33

44
const UseScrollInfo: React.FC = () => {

demo/WithScrollInfo.demo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { withScrollInfo } from '../src'; // swap '../src' for '../dist/build.bundle' to demo production build
2-
import { IScrollInfoContext } from '../src/ScrollInfoProvider/context';
1+
import { withScrollInfo } from '@faceless-ui/scroll-info';
2+
import type { IScrollInfoContext } from '../src/types';
33
import LogProps from './LogProps';
44

55
const WithScrollInfo: React.FC<{

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"name": "Jacob Fletcher",
1212
"url": "https://jacobsfletch.com"
1313
},
14+
"type": "module",
1415
"bugs": {
1516
"url": "https://github.com/faceless-ui/scroll-info/issues",
1617
"email": "dev@facelessui.com"
@@ -32,9 +33,9 @@
3233
"ux"
3334
],
3435
"scripts": {
35-
"build": "yarn lint && tsc",
36-
"build-demo": "yarn lint && webpack --config webpack.demo.config.js",
37-
"dev": "webpack-dev-server --hot --config webpack.development.config.js",
36+
"build": "yarn lint && tsc --project tsconfig.build.json",
37+
"build:demo": "yarn lint && webpack --config webpack.build-demo.config.js",
38+
"dev": "webpack-dev-server --hot --config webpack.dev.config.js",
3839
"lint": "eslint .",
3940
"test": "jest"
4041
},
@@ -44,13 +45,12 @@
4445
},
4546
"devDependencies": {
4647
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
47-
"@types/jest": "^27.4.1",
4848
"@types/node": "^14.14.22",
4949
"@types/react": "^18.0.0",
5050
"@types/react-dom": "^18.0.0",
51-
"@typescript-eslint/eslint-plugin": "^5.18.0",
52-
"@typescript-eslint/parser": "^5.18.0",
53-
"eslint": "^8.14.0",
51+
"@typescript-eslint/eslint-plugin": "^7.3.1",
52+
"@typescript-eslint/parser": "^7.3.1",
53+
"eslint": "^8.56.0",
5454
"eslint-plugin-import": "^2.26.0",
5555
"eslint-plugin-jest": "^26.1.5",
5656
"eslint-plugin-jest-dom": "^4.0.1",
@@ -65,11 +65,11 @@
6565
"react-dom": "^19.0.0-rc.0",
6666
"react-refresh": "^0.13.0",
6767
"react-refresh-typescript": "^2.0.4",
68-
"ts-loader": "^9.2.9",
69-
"typescript": "^4.6.3",
70-
"webpack": "^5.72.0",
71-
"webpack-cli": "^4.9.2",
72-
"webpack-dev-server": "^4.8.1"
68+
"ts-loader": "^9.5.1",
69+
"typescript": "^5.4.5",
70+
"webpack": "^5.91.0",
71+
"webpack-cli": "^5.1.4",
72+
"webpack-dev-server": "^5.0.4"
7373
},
7474
"files": [
7575
"dist"

src/ScrollInfo/index.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import React, { Fragment } from 'react';
2-
import useScrollInfo from '../useScrollInfo';
3-
import { IScrollInfoContext } from '../ScrollInfoProvider/context';
2+
import { useScrollInfo } from '../useScrollInfo/index.js';
3+
import { IScrollInfoContext } from '../ScrollInfoProvider/context.js';
44

55
export type ChildFunction = (context: IScrollInfoContext) => React.ReactNode; // eslint-disable-line no-unused-vars
66

77
export type ScrollInfoProps = {
88
children?: React.ReactNode | ChildFunction
99
}
1010

11-
const ScrollInfo: React.FC<ScrollInfoProps> = (props) => {
11+
export const ScrollInfo: React.FC<ScrollInfoProps> = (props) => {
1212
const { children } = props;
1313
const scrollInfo = useScrollInfo();
1414

@@ -29,5 +29,3 @@ const ScrollInfo: React.FC<ScrollInfoProps> = (props) => {
2929
}
3030
return null;
3131
};
32-
33-
export default ScrollInfo;

src/ScrollInfoProvider/context.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@ export interface IScrollInfoContext {
1414
hasScrolled: boolean,
1515
}
1616

17-
const ScrollInfoContext = createContext<IScrollInfoContext>({} as IScrollInfoContext);
18-
19-
export default ScrollInfoContext;
17+
export const ScrollInfoContext = createContext<IScrollInfoContext>({} as IScrollInfoContext);

src/ScrollInfoProvider/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React, {
44
useReducer,
55
useRef,
66
} from 'react';
7-
import ScrollInfoContext, { IScrollInfoContext } from '../ScrollInfoProvider/context';
7+
import { ScrollInfoContext, IScrollInfoContext } from '../ScrollInfoProvider/context.js';
88

99
type AnimationRef = React.MutableRefObject<number | null>;
1010

@@ -73,7 +73,7 @@ export type ScrollInfoProviderProps = {
7373
children: React.ReactNode
7474
}
7575

76-
const ScrollInfoProvider: React.FC<ScrollInfoProviderProps> = (props) => {
76+
export const ScrollInfoProvider: React.FC<ScrollInfoProviderProps> = (props) => {
7777
const {
7878
children,
7979
} = props;
@@ -135,5 +135,3 @@ const ScrollInfoProvider: React.FC<ScrollInfoProviderProps> = (props) => {
135135
</ScrollInfoContext.Provider>
136136
);
137137
};
138-
139-
export default ScrollInfoProvider;

src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export { default as ScrollInfo } from './ScrollInfo';
2-
export { default as ScrollInfoContext } from './ScrollInfoProvider/context';
3-
export { default as ScrollInfoProvider } from './ScrollInfoProvider';
4-
export { default as useScrollInfo } from './useScrollInfo';
5-
export { default as withScrollInfo } from './withScrollInfo';
1+
export { ScrollInfo } from './ScrollInfo/index.js';
2+
export { ScrollInfoContext } from './ScrollInfoProvider/context.js';
3+
export { ScrollInfoProvider } from './ScrollInfoProvider/index.js';
4+
export { useScrollInfo } from './useScrollInfo/index.js';
5+
export { withScrollInfo } from './withScrollInfo/index.js';

0 commit comments

Comments
 (0)