-
I want to publish my packages however I have a problem with In development environment: {
"name": "ui",
"version": "0.0.0",
"main": "./index.tsx",
"license": "MIT"
} This is what I want when I publish the package: {
"name": "ui",
"version": "0.0.0",
"main": "./dist/index.js",
"types": "./types/index.d.ts",
"license": "MIT"
} I know this is not turborepo problem but can anyone help me? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
At present, my method is to generate a template project through cli and then build it. The former standardizes the basic structure of lib, and the latter implements the function of zero-configuration packaging on top of this. You can refer to: https://www.npmjs.com/package/@liuli-util/cli
|
Beta Was this translation helpful? Give feedback.
-
From their docs:
|
Beta Was this translation helpful? Give feedback.
-
FWIW - we have solved this one for ourselves by patching the So when we do a release - we do these steps (in order) inside cicd:
the (ts-node) code which does the patching looks like this: import fs from "fs/promises";
type PackageNames = "react" | "tokens";
type JsonData = {
main: "./dist/index.js" | "./src/index.ts";
types: "./dist/index.d.ts" | "./src/index.ts";
};
export const DIST_PATHS: JsonData = {
main: "./dist/index.js",
types: "./dist/index.d.ts",
};
export const SRC_PATHS: JsonData = {
main: "./src/index.ts",
types: "./src/index.ts",
};
export function readPackageFileBuffer(packageName: PackageNames) {
return fs.readFile(`./packages/${packageName}/package.json`, "utf8");
}
export function patchPackageData(data: string, PATHS: JsonData) {
const parsed = JSON.parse(data);
parsed.main = PATHS.main;
parsed.types = PATHS.types;
return JSON.stringify(parsed, null, 2);
}
export function writeToPackage(packageName: PackageNames, data: string) {
return fs.writeFile(`./packages/${packageName}/package.json`, data);
}
export async function patchPackageFile(
packageName: PackageNames,
PATHS: JsonData
) {
const data = await readPackageFileBuffer(packageName);
writeToPackage(packageName, patchPackageData(data, PATHS));
} |
Beta Was this translation helpful? Give feedback.
link changed:
https://turbo.build/repo/docs/handbook/publishing-packages/versioning-and-publishing