diff --git a/scripts/build_npm.ts b/scripts/build_npm.ts index e2852eb..a2eb72b 100644 --- a/scripts/build_npm.ts +++ b/scripts/build_npm.ts @@ -1,4 +1,4 @@ -import { build, emptyDir, copy } from "./deps.ts"; +import { build, copy, emptyDir } from "./deps.ts"; // Clear NPM directory await emptyDir("./npm"); @@ -16,7 +16,7 @@ await build({ mappings: { "https://deno.land/x/zipjs@v2.7.17/index.js": { name: "@zip.js/zip.js", - version: "^2.7.17" + version: "^2.7.17", }, }, package: { @@ -26,14 +26,14 @@ await build({ description: "ENTSO-e transparency platform API Client. Complete. Easy to use. Minimal.", license: "MIT", repository: { - type: "git", - url: "git+https://github.com/Hexagon/entsoe-api-client.git" + type: "git", + url: "git+https://github.com/Hexagon/entsoe-api-client.git", }, author: "Hexagon ", bugs: { - url: "https://github.com/Hexagon/entsoe-api-client/issues" + url: "https://github.com/Hexagon/entsoe-api-client/issues", }, - homepage: "https://github.com/Hexagon/entsoe-api-client#readme" + homepage: "https://github.com/Hexagon/entsoe-api-client#readme", }, }); @@ -41,11 +41,19 @@ await build({ Deno.copyFileSync("LICENSE", "npm/LICENSE"); Deno.copyFileSync("README.md", "npm/README.md"); -// npmignore test data -// ensure the test data is ignored in the `.npmignore` file -// so it doesn't get published with your npm package +// Fix the .npmignore file to prevent exclusion of esm/src/ and script/src/ +// DNT 0.37.0 generates "src/" in .npmignore by default (when not using source maps). +// This pattern inadvertently excludes esm/src/ and script/src/ containing transpiled code. +// Replace "src/" with "/src/" to only match the root TypeScript source directory. +let npmignore = await Deno.readTextFile("npm/.npmignore"); +npmignore = npmignore.replace(/^src\/$/m, "/src/"); +await Deno.writeTextFile("npm/.npmignore", npmignore); + +// npmignore test data and test declaration files +// ensure the test data and generated test .d.ts files are ignored in the `.npmignore` file +// so they don't get published with your npm package await Deno.writeTextFile( "npm/.npmignore", - "esm/tests/data\nscript/tests/data\n", + "esm/tests/data\nscript/tests/data\n*.test.d.ts\ntests/**/*.d.ts\n", { append: true }, -); \ No newline at end of file +);