Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: export PackageJsonObject #295

Merged
merged 8 commits into from
May 19, 2023
Merged

feat: export PackageJsonObject #295

merged 8 commits into from
May 19, 2023

Conversation

UrielCh
Copy link
Contributor

@UrielCh UrielCh commented May 19, 2023

Hi,

I'm writing a lot of dnt scripts currently, and I want them to be supper clean.

Right now my common don't script starts like this:

// dnt deps can not be moved to dev_deps.ts
import { build, emptyDir } from "https://deno.land/x/dnt@0.35.0/mod.ts";
import * as pc from "https://deno.land/std@0.188.0/fmt/colors.ts";
import { PackageJsonObject } from "https://deno.land/x/dnt@0.35.0/lib/types.ts";

and later I write my dnt build call like that:

const packageJson: PackageJsonObject = {
  name: "....",
  author: "...",
  license: "...",
  contributors: [
    "..."
  ],
  description: "...",
  keywords: [
    "...",
    "...",
  ],
  private: false,
  homepage: "...",
  version,
  /// ...
};
await emptyDir("./npm");
await build({
  entryPoints: ["./mod.ts"],
  outDir: "./npm",
  shims: {
    deno: true,
  },
  compilerOptions: {},
  package: packageJson,
});

For a clean code, I need to explicitly use type PackageJsonObject

with that change, the top of ma build script can be written:

// dnt deps can not be moved to dev_deps.ts
import { build, emptyDir, PackageJsonObject  } from "https://deno.land/x/dnt@0.35.0/mod.ts";
import * as pc from "https://deno.land/std@0.188.0/fmt/colors.ts";

that cleaner, and avoid repetition of dnt@0.35.0

I think I can be categorized as a "never nester"

I will put my ultimate dnt_build script in the doc at the end.

@dsherret dsherret changed the title improve dnt import/export in mod.ts feat: export PackageJsonObject May 19, 2023
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dsherret
Copy link
Member

I'm going to rename this as PackageJson in a future PR. The Object seems unnecessary.

@dsherret dsherret merged commit 45f2a23 into denoland:main May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants