diff --git a/.eslintrc.js b/.eslintrc.js index fb1d27d..626a217 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -29,7 +29,12 @@ module.exports = { }, }, extends: baseExtends, - ignorePatterns: ["dist/**/*", "jest.config*"], + ignorePatterns: [ + "dist/**/*", + "jest.config*", + "useScriptLoader/index.d.ts", + "scriptloader-support/index.d.ts", + ], env: { es6: true }, parserOptions: { ecmaVersion: 2021, sourceType: "module" }, overrides: [ diff --git a/package.json b/package.json index 7b10912..70c301b 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,10 @@ ], "scripts": { "test": "eslint --quiet . && tsc --noEmit --project ./tsconfig.json && jest", - "build": "tsc --project ./tsconfig.json", + "build": "npm run build:base && npm run build:useScriptLoader && npm run build:scriptloader-support", + "build:base": "tsc --project ./tsconfig.json", + "build:useScriptLoader": "tsc --project ./useScriptLoader/tsconfig.json", + "build:scriptloader-support": "tsc --project ./scriptloader-support/tsconfig.json", "prepack": "npm run build" }, "repository": { diff --git a/scriptloader-support/index.d.ts b/scriptloader-support/index.d.ts index b016813..67ae669 100644 --- a/scriptloader-support/index.d.ts +++ b/scriptloader-support/index.d.ts @@ -1 +1,2 @@ -export * from "../src/scriptloader-support"; +export = supportExports; +import supportExports = require("../dist/scriptloader-support"); diff --git a/scriptloader-support/tsconfig.json b/scriptloader-support/tsconfig.json new file mode 100644 index 0000000..7271af7 --- /dev/null +++ b/scriptloader-support/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.json", + "include": ["./index.js"], + "exclude": [], + "compilerOptions": { + "emitDeclarationOnly": true, + "rootDir": "./", + "outDir": "./" + } +} diff --git a/src/hooks/useScriptLoader.ts b/src/hooks/useScriptLoader.ts index 4395dd1..ba2ec9c 100644 --- a/src/hooks/useScriptLoader.ts +++ b/src/hooks/useScriptLoader.ts @@ -11,7 +11,7 @@ export interface ScriptLoader { (config: ScriptLoaderConfiguration): void; } -const useScriptLoader: ScriptLoader = (config) => { +export default (function useScriptLoader(config) { const { source, onSuccess, @@ -40,6 +40,4 @@ const useScriptLoader: ScriptLoader = (config) => { }; void waitForSource(); }, [source, successFunc, errorFunc]); -}; - -export default useScriptLoader; +} as ScriptLoader); diff --git a/useScriptLoader/index.d.ts b/useScriptLoader/index.d.ts index 87d0252..eeb7dd2 100644 --- a/useScriptLoader/index.d.ts +++ b/useScriptLoader/index.d.ts @@ -1 +1,2 @@ -export * from "../src/hooks/useScriptLoader"; +export = useScriptLoaderExports; +import useScriptLoaderExports = require("../dist/hooks/useScriptLoader"); diff --git a/useScriptLoader/tsconfig.json b/useScriptLoader/tsconfig.json new file mode 100644 index 0000000..7271af7 --- /dev/null +++ b/useScriptLoader/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.json", + "include": ["./index.js"], + "exclude": [], + "compilerOptions": { + "emitDeclarationOnly": true, + "rootDir": "./", + "outDir": "./" + } +}