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: output dir config & remove dep on pkg 'main' #31

Merged
merged 3 commits into from Aug 29, 2021

Conversation

zxch3n
Copy link
Collaborator

@zxch3n zxch3n commented Aug 29, 2021

  • Add output dir config
  • Use warning instead of throw when mod.ts cannot be generated. Currently denoify requires that package.json main should be inside tsconfig.outDir. It causes denoify cannot work on some projects and there is no workaround.

Copy link
Owner

@garronej garronej left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

@@ -12,6 +12,7 @@ commanderStatic
`)
.option("-p, --project [projectPath]", `Default: './' -- Root path of the project to denoify, target directory is supposed to contain a 'package.json' and 'tsconfig.json'.`)
.option("--src [srcDirPath]", `Default: '[projectPath]/src' | '[projectPath]/lib' -- Path to the directory containing the source .ts files. If the provided path is not absolute it is assumed relative to [projectPath]`)
.option("--out [outputDirPath]", `Default: '$(dirname <tsconfig.outDir>)/deno_lib' -- Path to the output directory`)
Copy link
Owner

Choose a reason for hiding this comment

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

I like it

Comment on lines -61 to -77
if (!("main" in packageJsonParsed)) {
//TODO: We shouldn't force users to specify a default export.
throw new Error([
"A main field in package.json need to be specified",
"otherwise we don't know what file the mod.ts should export."
].join(" "));
}

if (
!isInsideOrIsDir({
"dirPath": tsconfigOutDir,
"fileOrDirPath": path.normalize(packageJsonParsed["main"])
})
) {
throw new Error(`The package.json main should point to a file inside ${tsconfigOutDir}`)
}

Copy link
Owner

Choose a reason for hiding this comment

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

I no longer have all the context in mind to remember why I deemed important to have this fail early strategy here.
I am willing to trust you on the fact that it can be safely removed.

@garronej garronej merged commit 2c09ae4 into garronej:master Aug 29, 2021
@garronej
Copy link
Owner

I just released a new version featuring your changes

gitbook-com bot pushed a commit that referenced this pull request Oct 23, 2022
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.

None yet

2 participants