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

Revert "Migrate out of typesVersions in package.json and cleanup" #2554

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

14 changes: 7 additions & 7 deletions docs/extending-typespec/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,13 @@ export const MyTestLibrary = createTestLibrary({
// ...
"main": "dist/src/index.js",
"exports": {
".": {
"default": "./dist/src/index.js",
"types": "./dist/src/index.d.ts"
},
"./testing": {
"default": "./dist/src/testing/index.js",
"types": "./dist/src/testing/index.d.ts"
".": "./dist/src/index.js",
"./testing": "./dist/src/testing/index.js"
},
"typesVersions": {
"*": {
"*": ["./dist/src/index.d.ts"],
"testing": ["./dist/src/testing/index.d.ts"]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/best-practices/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": "Microsoft Corporation",
"description": "TypeSpec linter rules to enforce best practices.",
"homepage": "https://microsoft.github.io/typespec",
"readme": "https://github.com/microsoft/typespec/blob/main/README.md",
"readme": "https://github.com/microsoft/typespec/blob/master/README.md",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/bundler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": "Microsoft Corporation",
"description": "Package to bundle a typespec library.",
"homepage": "https://microsoft.github.io/typespec",
"readme": "https://github.com/microsoft/typespec/blob/main/README.md",
"readme": "https://github.com/microsoft/typespec/blob/master/README.md",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
18 changes: 3 additions & 15 deletions packages/bundler/src/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ export interface TypeSpecBundleDefinition {
path: string;
main: string;
packageJson: PackageJson;
exports: Record<string, string | ExportData>;
}

export interface ExportData {
default: string;
types?: string;
exports: Record<string, string>;
}

export interface TypeSpecBundle {
Expand Down Expand Up @@ -153,10 +148,7 @@ async function createRollupConfig(definition: TypeSpecBundleDefinition): Promise

const extraEntry = Object.fromEntries(
Object.entries(definition.exports).map(([key, value]) => {
return [
key.replace("./", ""),
normalizePath(resolve(libraryPath, getExportEntryPoint(value))),
];
return [key.replace("./", ""), normalizePath(resolve(libraryPath, value))];
})
);
return {
Expand Down Expand Up @@ -203,19 +195,15 @@ async function generateTypeSpecBundle(
files: output
.filter((x): x is OutputChunk => "code" in x)
.map((chunk) => {
const entry = definition.exports[basename(chunk.fileName)];
return {
filename: chunk.fileName,
content: chunk.code,
export: entry ? getExportEntryPoint(entry) : undefined,
export: definition.exports[basename(chunk.fileName)],
};
}),
};
}

function getExportEntryPoint(value: string | ExportData) {
return typeof value === "string" ? value : value.default;
}
async function readLibraryPackageJson(path: string): Promise<PackageJson> {
const file = await readFile(join(path, "package.json"));
return JSON.parse(file.toString());
Expand Down
38 changes: 21 additions & 17 deletions packages/compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Microsoft Corporation",
"license": "MIT",
"homepage": "https://microsoft.github.io/typespec",
"readme": "https://github.com/microsoft/typespec/blob/main/README.md",
"readme": "https://github.com/microsoft/typespec/blob/master/README.md",
"repository": {
"type": "git",
"url": "git+https://github.com/microsoft/typespec.git"
Expand All @@ -21,27 +21,31 @@
"main": "dist/src/index.js",
"tspMain": "lib/main.tsp",
"exports": {
".": {
"default": "./dist/src/index.js",
"types": "./dist/src/index.d.ts"
},
"./testing": {
"default": "./dist/src/testing/index.js",
"types": "./dist/src/testing/index.d.ts"
},
"./module-resolver": {
"default": "./dist/src/core/module-resolver.js",
"types": "./dist/src/core/module-resolver.d.ts"
},
"./emitter-framework": {
"default": "./dist/src/emitter-framework/index.js",
"types": "./dist/src/emitter-framework/index.d.ts"
}
".": "./dist/src/index.js",
"./testing": "./dist/src/testing/index.js",
"./module-resolver": "./dist/src/core/module-resolver.js",
"./emitter-framework": "./dist/src/emitter-framework/index.js"
},
"browser": {
"./dist/src/core/node-host.js": "./dist/src/core/node-host.browser.js",
"./dist/src/core/logger/console-sink.js": "./dist/src/core/logger/console-sink.browser.js"
},
"typesVersions": {
"*": {
"*": [
"./dist/src/index.d.ts"
],
"testing": [
"./dist/src/testing/index.d.ts"
],
"module-resolver": [
"./dist/src/core/module-resolver.d.ts"
],
"emitter-framework": [
"./dist/src/emitter-framework/index.d.ts"
]
}
},
"engines": {
"node": ">=16.0.0"
},
Expand Down
20 changes: 12 additions & 8 deletions packages/html-program-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": "Microsoft Corporation",
"description": "TypeSpec library for emitting an html view of the program.",
"homepage": "https://microsoft.github.io/typespec",
"readme": "https://github.com/microsoft/typespec/blob/main/README.md",
"readme": "https://github.com/microsoft/typespec/blob/master/README.md",
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -19,13 +19,17 @@
"type": "module",
"main": "dist/src/index.js",
"exports": {
".": {
"default": "./dist/src/index.js",
"types": "./dist/src/index.d.ts"
},
"./testing": {
"default": "./dist/src/testing/index.js",
"types": "./dist/src/testing/index.d.ts"
".": "./dist/src/index.js",
"./testing": "./dist/src/testing/index.js"
},
"typesVersions": {
"*": {
"*": [
"./dist/src/index.d.ts"
],
"testing": [
"./dist/src/testing/index.d.ts"
]
}
},
"tspMain": "dist/src/index.js",
Expand Down
20 changes: 12 additions & 8 deletions packages/http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": "Microsoft Corporation",
"description": "TypeSpec HTTP protocol binding",
"homepage": "https://github.com/microsoft/typespec",
"readme": "https://github.com/microsoft/typespec/blob/main/README.md",
"readme": "https://github.com/microsoft/typespec/blob/master/README.md",
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -20,13 +20,17 @@
"main": "dist/src/index.js",
"tspMain": "lib/http.tsp",
"exports": {
".": {
"default": "./dist/src/index.js",
"types": "./dist/src/index.d.ts"
},
"./testing": {
"default": "./dist/src/testing/index.js",
"types": "./dist/src/testing/index.d.ts"
".": "./dist/src/index.js",
"./testing": "./dist/src/testing/index.js"
},
"typesVersions": {
"*": {
"*": [
"./dist/src/index.d.ts"
],
"testing": [
"./dist/src/testing/index.d.ts"
]
}
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/internal-build-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": "Microsoft Corporation",
"description": "Internal library to TypeSpec providing helpers to build.",
"homepage": "https://microsoft.github.io/typespec",
"readme": "https://github.com/microsoft/typespec/blob/main/README.md",
"readme": "https://github.com/microsoft/typespec/blob/master/README.md",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
Loading
Loading