Skip to content

Commit 97e7ba4

Browse files
authored
chore: nodenext module resolution (#57)
1 parent f5f0724 commit 97e7ba4

File tree

15 files changed

+99
-79
lines changed

15 files changed

+99
-79
lines changed

demo/App/index.tsx renamed to demo/App.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React from 'react';
22
import { ModalProvider, ModalContainer, ModalToggler } from '@faceless-ui/modal';
3-
import AsModal from '../AsModalDemo';
4-
import UseModal from '../UseModalDemo';
5-
import Modal from '../ModalDemo';
6-
import CSS from '../CSS';
7-
import SettingsControls from '../SettingsControls';
8-
import { SettingsProvider } from '../SettingsProvider';
3+
import AsModal from './AsModalDemo/index.js';
4+
import UseModal from './UseModalDemo/index.js';
5+
import Modal from './ModalDemo/index.js';
6+
import CSS from './CSS.js';
7+
import SettingsControls from './SettingsControls/index.js';
8+
import { SettingsProvider } from './SettingsProvider/index.js';
99
// import Test from '../Test';
1010

1111
const App: React.FC = () => {

demo/AsModalDemo/reducer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Settings, IReducerAction } from './types';
1+
import { Settings, IReducerAction } from './types.js';
22

33
const reducer = (state: Settings, action: IReducerAction): Settings => {
44
const { payload } = action;

demo/ModalControls/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Fragment } from 'react';
22
import { useModal, ModalToggler } from '@faceless-ui/modal';
3-
import type {ModalPropsWithContext} from '../../src/Modal';
3+
import type { ModalPropsWithContext } from '../../src/Modal/index.js';
44
import { useSettings } from '../SettingsProvider/index.js';
55

66
const ModalControls: React.FC<ModalPropsWithContext> = (props) => {

demo/ModalDemo/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, { Fragment } from 'react';
22
import { Modal, ModalToggler } from '@faceless-ui/modal';
3-
import LogProps from '../LogProps';
4-
import ModalControls from '../ModalControls';
5-
import { SettingsProvider } from '../SettingsProvider';
3+
import LogProps from '../LogProps/index.js';
4+
import ModalControls from '../ModalControls/index.js';
5+
import { SettingsProvider } from '../SettingsProvider/index.js';
66

77
const ModalDemo: React.FC = () => {
88

demo/ModalDemo/reducer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Settings, IReducerAction } from './types';
1+
import { Settings, IReducerAction } from './types.js';
22

33
const reducer = (state: Settings, action: IReducerAction): Settings => {
44
const { payload } = action;

demo/SettingsControls/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Fragment } from 'react';
22
import { useModal } from '@faceless-ui/modal';
3-
import { useSettings } from '../SettingsProvider';
3+
import { useSettings } from '../SettingsProvider/index.js';
44

55
const SettingsControls: React.FC = () => {
66
const { dispatchSettings } = useSettings();

demo/SettingsProvider/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { createContext, useContext, useReducer } from 'react';
2-
import reducer from './reducer'
2+
import reducer from './reducer.js'
33

44
export type Settings = Record<string, unknown>;
55

demo/SettingsProvider/reducer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Settings, IReducerAction } from './';
1+
import { Settings, IReducerAction } from './index.js';
22

33
const reducer = (state: Settings, action: IReducerAction): Settings => {
44
const { payload } = action;

demo/UseModalDemo/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { useModal } from '@faceless-ui/modal';
3-
import LogProps from '../LogProps';
3+
import LogProps from '../LogProps/index.js';
44

55
const UseModal: React.FC = (props) => {
66
const modal = useModal();

demo/index.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 App from './App';
2+
import App from './App.js';
33
import { createRoot } from 'react-dom/client';
44
const container = document.getElementById('root');
55
if (container) {

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@faceless-ui/modal",
33
"version": "3.0.0-beta.0",
4+
"type": "module",
45
"main": "dist/index.js",
56
"types": "dist/index.d.ts",
67
"homepage:": "https://facelessui.com/docs/modal",
@@ -11,7 +12,6 @@
1112
"name": "Faceless UI",
1213
"url": "https://facelessui.com"
1314
},
14-
"type": "module",
1515
"bugs": {
1616
"url": "https://github.com/faceless-ui/modal/issues",
1717
"email": "[email protected]"
@@ -44,10 +44,11 @@
4444
"ux"
4545
],
4646
"scripts": {
47-
"build": "yarn lint && tsc --project tsconfig.build.json",
48-
"build:demo": "yarn lint && webpack --config webpack.build-demo.config.js",
49-
"dev": "webpack-dev-server --hot --config webpack.dev.config.js",
50-
"lint": "eslint .",
47+
"build": "yarn lint:src && tsc --project tsconfig.build.json",
48+
"build:demo": "webpack --config webpack.build-demo.config.js",
49+
"dev": "webpack serve --config webpack.dev.config.js",
50+
"lint:src": "eslint ./src",
51+
"lint:demo": "eslint ./demo",
5152
"test": "jest"
5253
},
5354
"peerDependencies": {
@@ -70,6 +71,7 @@
7071
"@types/react-transition-group": "^4.4.4",
7172
"@typescript-eslint/eslint-plugin": "^7.3.1",
7273
"@typescript-eslint/parser": "^7.3.1",
74+
"@types/webpack": "^5.28.5",
7375
"eslint": "^8.56.0",
7476
"eslint-plugin-import": "^2.26.0",
7577
"eslint-plugin-jest": "^26.1.5",

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"outDir": "./dist",
44
"allowJs": true,
55
"target": "es6",
6-
"module": "ESNext",
7-
"moduleResolution": "node",
6+
"module": "NodeNext",
7+
"moduleResolution": "NodeNext",
88
"resolveJsonModule": true,
99
"strict": true,
1010
"sourceMap": true,

webpack.build-demo.config.js

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,48 @@ import { fileURLToPath } from 'node:url'
55
const filename = fileURLToPath(import.meta.url)
66
const dirname = path.dirname(filename)
77

8-
export default [
9-
{
10-
devtool: 'source-map',
11-
mode: 'production',
12-
entry: path.resolve(dirname, 'demo/index.tsx'),
13-
output: {
14-
filename: 'demo.bundle.js',
15-
path: path.resolve(dirname, 'dist-demo'),
16-
},
17-
module: {
18-
rules: [
19-
{
20-
test: /\.(js|jsx|ts|tsx)$/,
21-
exclude: /node_modules/,
22-
use: [{
23-
loader: 'ts-loader',
24-
options: {
25-
configFile: 'tsconfig.json',
26-
compilerOptions: {
27-
outDir: "./dist-demo",
28-
declarationDir: undefined,
29-
declaration: false
30-
},
8+
const config = {
9+
devtool: 'source-map',
10+
mode: 'production',
11+
entry: path.resolve(dirname, 'demo/index.tsx'),
12+
output: {
13+
filename: 'demo.bundle.js',
14+
path: path.resolve(dirname, 'dist-demo'),
15+
},
16+
module: {
17+
rules: [
18+
{
19+
test: /\.(js|jsx|ts|tsx)$/,
20+
exclude: /node_modules/,
21+
use: [{
22+
loader: 'ts-loader',
23+
options: {
24+
configFile: 'tsconfig.json',
25+
compilerOptions: {
26+
outDir: "./dist-demo",
27+
declarationDir: undefined,
28+
declaration: false
3129
},
32-
}],
33-
},
34-
],
35-
},
36-
resolve: {
37-
extensions: ['.ts', '.tsx', '.js', '.jsx'],
38-
alias: {
39-
'@faceless-ui/modal': path.resolve(dirname, 'src/index.ts'),
30+
},
31+
}],
4032
},
41-
extensionAlias: {
42-
'.js': ['.ts', '.js', '.tsx', '.jsx'],
43-
'.mjs': ['.mts', '.mjs'],
44-
},
45-
},
46-
plugins: [
47-
new HtmlWebPackPlugin({
48-
template: 'demo/index.html',
49-
}),
5033
],
51-
}];
34+
},
35+
resolve: {
36+
extensions: ['.ts', '.tsx', '.js', '.jsx'],
37+
alias: {
38+
'@faceless-ui/modal': path.resolve(dirname, 'src/index.ts'),
39+
},
40+
extensionAlias: {
41+
'.js': ['.ts', '.js', '.tsx', '.jsx'],
42+
'.mjs': ['.mts', '.mjs'],
43+
},
44+
},
45+
plugins: [
46+
new HtmlWebPackPlugin({
47+
template: 'demo/index.html',
48+
}),
49+
],
50+
}
51+
52+
export default config;

webpack.dev.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ESLintPlugin from 'eslint-webpack-plugin';
77
const filename = fileURLToPath(import.meta.url)
88
const dirname = path.dirname(filename)
99

10-
export default {
10+
const config = {
1111
devtool: 'inline-source-map',
1212
mode: 'development',
1313
entry: path.resolve(dirname, 'demo/index.tsx'),
@@ -22,6 +22,11 @@ export default {
2222
loader: 'ts-loader',
2323
options: {
2424
transpileOnly: true,
25+
compilerOptions: {
26+
module: "commonjs",
27+
target: "es5",
28+
moduleResolution: "node",
29+
}
2530
},
2631
}
2732
],
@@ -49,5 +54,8 @@ export default {
4954
devServer: {
5055
port: 3000,
5156
host: '0.0.0.0',
57+
hot: true,
5258
},
5359
};
60+
61+
export default config;

yarn.lock

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,15 @@
10131013
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8"
10141014
integrity sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==
10151015

1016+
"@types/webpack@^5.28.5":
1017+
version "5.28.5"
1018+
resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-5.28.5.tgz#0e9d9a15efa09bbda2cef41356ca4ac2031ea9a2"
1019+
integrity sha512-wR87cgvxj3p6D0Crt1r5avwqffqPXUkNlnQ1mjU93G7gCuFjufZR4I6j8cz5g1F1tTYpfOOFvly+cmIQwL9wvw==
1020+
dependencies:
1021+
"@types/node" "*"
1022+
tapable "^2.2.0"
1023+
webpack "^5"
1024+
10161025
"@types/ws@^8.5.10":
10171026
version "8.5.10"
10181027
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.10.tgz#4acfb517970853fa6574a3a6886791d04a396787"
@@ -1738,14 +1747,14 @@ braces@^3.0.3, braces@~3.0.2:
17381747
fill-range "^7.1.1"
17391748

17401749
browserslist@^4.21.10, browserslist@^4.22.2:
1741-
version "4.23.0"
1742-
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.23.0.tgz#8f3acc2bbe73af7213399430890f86c63a5674ab"
1743-
integrity sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==
1750+
version "4.23.1"
1751+
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.23.1.tgz#ce4af0534b3d37db5c1a4ca98b9080f985041e96"
1752+
integrity sha512-TUfofFo/KsK/bWZ9TWQ5O26tsWW4Uhmt8IYklbnUa70udB6P2wA7w7o4PY4muaEPBQaAX+CEnmmIA41NVHtPVw==
17441753
dependencies:
1745-
caniuse-lite "^1.0.30001587"
1746-
electron-to-chromium "^1.4.668"
1754+
caniuse-lite "^1.0.30001629"
1755+
electron-to-chromium "^1.4.796"
17471756
node-releases "^2.0.14"
1748-
update-browserslist-db "^1.0.13"
1757+
update-browserslist-db "^1.0.16"
17491758

17501759
17511760
version "2.1.1"
@@ -1810,7 +1819,7 @@ camelcase@^6.2.0:
18101819
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a"
18111820
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
18121821

1813-
caniuse-lite@^1.0.30001587:
1822+
caniuse-lite@^1.0.30001629:
18141823
version "1.0.30001629"
18151824
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001629.tgz#907a36f4669031bd8a1a8dbc2fa08b29e0db297e"
18161825
integrity sha512-c3dl911slnQhmxUIT4HhYzT7wnBK/XYpGnYLOj4nJBaRiw52Ibe7YxlDaAeRECvA786zCuExhxIUJ2K7nHMrBw==
@@ -2319,10 +2328,10 @@ [email protected]:
23192328
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
23202329
integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==
23212330

2322-
electron-to-chromium@^1.4.668:
2323-
version "1.4.795"
2324-
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.795.tgz#25d05961c529bc32435e5e4abdd8f9dabcbc9dc5"
2325-
integrity sha512-hHo4lK/8wb4NUa+NJYSFyJ0xedNHiR6ylilDtb8NUW9d4dmBFmGiecYEKCEbti1wTNzbKXLfl4hPWEkAFbHYlw==
2331+
electron-to-chromium@^1.4.796:
2332+
version "1.4.796"
2333+
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.796.tgz#48dd6ff634b7f7df6313bd27aaa713f3af4a2b29"
2334+
integrity sha512-NglN/xprcM+SHD2XCli4oC6bWe6kHoytcyLKCWXmRL854F0qhPhaYgUswUsglnPxYaNQIg2uMY4BvaomIf3kLA==
23262335

23272336
emittery@^0.10.2:
23282337
version "0.10.2"
@@ -5853,7 +5862,7 @@ [email protected], unpipe@~1.0.0:
58535862
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
58545863
integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==
58555864

5856-
update-browserslist-db@^1.0.13:
5865+
update-browserslist-db@^1.0.16:
58575866
version "1.0.16"
58585867
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz#f6d489ed90fb2f07d67784eb3f53d7891f736356"
58595868
integrity sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ==
@@ -6005,7 +6014,7 @@ webpack-sources@^3.2.3:
60056014
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde"
60066015
integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==
60076016

6008-
webpack@^5.91.0:
6017+
webpack@^5, webpack@^5.91.0:
60096018
version "5.91.0"
60106019
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.91.0.tgz#ffa92c1c618d18c878f06892bbdc3373c71a01d9"
60116020
integrity sha512-rzVwlLeBWHJbmgTC/8TvAcu5vpJNII+MelQpylD4jNERPwpBJOE2lEcko1zJX3QJeLjTTAnQxn/OJ8bjDzVQaw==

0 commit comments

Comments
 (0)