diff --git a/scripts/copy-files.js b/scripts/copy-files.js index 99379e2..26f437e 100644 --- a/scripts/copy-files.js +++ b/scripts/copy-files.js @@ -43,6 +43,19 @@ const srcPath = path.join(packagePath, "./src"); // ); // } +async function typescriptCopy({ from, to }) { + if (!(await fse.exists(to))) { + console.warn(`path ${to} does not exists`); + return []; + } + + const files = glob.sync("**/*.d.ts", { cwd: from }); + const cmds = files.map(file => + fse.copy(path.resolve(from, file), path.resolve(to, file)) + ); + return Promise.all(cmds); +} + async function createPackageFile() { const packageData = await fse.readFile( path.resolve(packagePath, "./package.json"), @@ -54,7 +67,9 @@ async function createPackageFile() { const newPackageData = { ...packageDataOther, private: false, - main: "./index.js" + main: "./index.js", + //module: "./esm/index.js", + typings: "./index.d.ts" }; const targetPath = path.resolve(buildPath, "./package.json"); @@ -77,6 +92,9 @@ async function run() { try { await createPackageFile(); + // TypeScript + await typescriptCopy({ from: srcPath, to: buildPath }); + //await createModulePackages({ from: srcPath, to: buildPath }); } catch (err) { console.error(err); diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..25297f6 --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1,4 @@ +import * as typeValidator from "./data/typeValidator"; +import * as localStorage from "./storage/localStorage"; + +export { typeValidator, localStorage };