-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
fix: npm and JSR package contents #16
Changes from all commits
ab25346
60c1495
9fef137
76f8f3a
6e1f656
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @fileoverview Prepends a TypeScript reference comment to the beginning of a file. | ||
* This is necessary because JSR requires that all JavaScript files have a reference | ||
* to the TypeScript types file. We can't do this in Rollup because that happens | ||
* before tsc is run. This script is run after tsc is run. | ||
* | ||
* Usage: | ||
* node tools/prepend-type-ref.js filename.js | ||
* | ||
* @author Nicholas C. Zakas | ||
*/ | ||
/* global process */ | ||
//----------------------------------------------------------------------------- | ||
// Imports | ||
//----------------------------------------------------------------------------- | ||
|
||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
|
||
//----------------------------------------------------------------------------- | ||
// Main | ||
//----------------------------------------------------------------------------- | ||
|
||
// read file from the command line | ||
const filePath = process.argv[2]; | ||
const filename = path.basename(filePath, ".js"); | ||
|
||
// read the file | ||
const contents = fs.readFileSync(filePath, "utf8"); | ||
|
||
// prepend the reference comment | ||
const newContents = `/// <reference types="./${filename}.d.ts" />\n${contents}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove the contents of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. As I said in the PR description, JSR errors without There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant to delete its contents and keep only the triple-slash directive. not delete this file |
||
|
||
// write the file back out | ||
fs.writeFileSync(filePath, newContents, "utf8"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
types.ts
again, we don't need it in npm.