diff --git a/.eslintrc.js b/.eslintrc.js index 7b7e7e2..fb1d27d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -29,7 +29,7 @@ module.exports = { }, }, extends: baseExtends, - ignorePatterns: ["dist/**/*"], + ignorePatterns: ["dist/**/*", "jest.config*"], env: { es6: true }, parserOptions: { ecmaVersion: 2021, sourceType: "module" }, overrides: [ @@ -52,7 +52,12 @@ module.exports = { }, }, { - files: ["./*.js", "./scriptloader-support/*.js", "./release/**"], + files: [ + "./*.js", + "./scriptloader-support/*.js", + "./useScriptLoader/*.js", + "./release/**", + ], env: { node: true }, }, { diff --git a/index.ts b/index.ts deleted file mode 100644 index f049b2c..0000000 --- a/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from "./src/ScriptLoader"; -export * from "./src/hooks/useScriptLoader"; -import useScriptLoader from "./src/hooks/useScriptLoader"; -export { useScriptLoader }; - -import ScriptLoader from "./src/ScriptLoader"; -export default ScriptLoader; diff --git a/package.json b/package.json index 685ddcf..522f4af 100644 --- a/package.json +++ b/package.json @@ -3,14 +3,12 @@ "version": "1.4.2", "description": "A React Component for reacting to scripts loading.", "main": "dist/index.js", - "exports": { - ".": "./dist/index.js", - "./scriptloader-support": "./dist/scriptloader-support/index.js" - }, + "module": "dist/index.js", "files": [ "dist", "src", - "scriptloader-support" + "scriptloader-support", + "useScriptLoader" ], "scripts": { "test": "eslint --quiet . && tsc --noEmit --project ./tsconfig.json && jest", diff --git a/scriptloader-support/index.js b/scriptloader-support/index.js index 01b71f5..9271368 100644 --- a/scriptloader-support/index.js +++ b/scriptloader-support/index.js @@ -1,2 +1,2 @@ -const supportExports = require("../dist/src/scriptloader-support"); +const supportExports = require("../dist/scriptloader-support"); module.exports = supportExports; diff --git a/src/ScriptLoader.tsx b/src/index.tsx similarity index 100% rename from src/ScriptLoader.tsx rename to src/index.tsx diff --git a/test/ScriptLoader.test.tsx b/test/ScriptLoader.test.tsx index 164fe7a..c93eecb 100644 --- a/test/ScriptLoader.test.tsx +++ b/test/ScriptLoader.test.tsx @@ -8,7 +8,7 @@ import { } from "msw"; import { setupServer } from "msw/node"; import { render, screen, waitFor } from "@testing-library/react"; -import ScriptLoader, { ScriptLoaderProps } from "../src/ScriptLoader"; +import ScriptLoader, { ScriptLoaderProps } from "../src/index"; type ResponseHandlerContext = typeof context; interface ResponseHandler { diff --git a/tsconfig.json b/tsconfig.json index dc77707..8bb5cc1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,9 +12,10 @@ "moduleResolution": "node", "target": "ES5", "typeRoots": ["node_modules/@types"], + "rootDir": "./src", "paths": { "scriptloader-support/*": ["./src/scriptloader-support/*"] } }, - "include": ["src", "./index.ts", "./jest.config.ts"] + "include": ["src"] } diff --git a/useScriptLoader/index.d.ts b/useScriptLoader/index.d.ts new file mode 100644 index 0000000..87d0252 --- /dev/null +++ b/useScriptLoader/index.d.ts @@ -0,0 +1 @@ +export * from "../src/hooks/useScriptLoader"; diff --git a/useScriptLoader/index.js b/useScriptLoader/index.js new file mode 100644 index 0000000..def77bd --- /dev/null +++ b/useScriptLoader/index.js @@ -0,0 +1,2 @@ +const useScriptLoaderExports = require("../dist/hooks/useScriptLoader"); +module.exports = useScriptLoaderExports;