Skip to content

Commit

Permalink
Merge branch 'main' into feature/website-design
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeguerin authored Oct 9, 2023
2 parents f11e6dd + e713281 commit 7454599
Show file tree
Hide file tree
Showing 68 changed files with 954 additions and 325 deletions.
2 changes: 0 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"**/dist-dev/**": true,
"**/.docusaurus/**": true,
"**/CHANGELOG.json": true,
"**/CHANGELOG.md": true,
"docs/spec.html": true,
"common/config/rush/pnpm-lock.yaml": true,
"**/node_modules/**": true,
"packages/website/versioned_docs/**": true,
"packages/samples/scratch/**": false // Those files are in gitignore but we still want to search for them
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/bundler",
"comment": "",
"type": "none"
}
],
"packageName": "@typespec/bundler"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/bundler",
"comment": "`TypeScript` use `types` entry under `exports` of `package.json` instead of legacy `typesVersions` to provide the definition files",
"type": "none"
}
],
"packageName": "@typespec/bundler"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/compiler",
"comment": "`TypeScript` use `types` entry under `exports` of `package.json` instead of legacy `typesVersions` to provide the definition files",
"type": "none"
}
],
"packageName": "@typespec/compiler"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/html-program-viewer",
"comment": "`TypeScript` use `types` entry under `exports` of `package.json` instead of legacy `typesVersions` to provide the definition files",
"type": "none"
}
],
"packageName": "@typespec/html-program-viewer"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/http",
"comment": "Add support for status code ranges for http responses. **Change to API** Http responses can now also return a `HttpStatusCodeRange` object for their status codes",
"type": "none"
}
],
"packageName": "@typespec/http"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/http",
"comment": "`TypeScript` use `types` entry under `exports` of `package.json` instead of legacy `typesVersions` to provide the definition files",
"type": "none"
}
],
"packageName": "@typespec/http"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/internal-build-utils",
"comment": "`TypeScript` use `types` entry under `exports` of `package.json` instead of legacy `typesVersions` to provide the definition files",
"type": "none"
}
],
"packageName": "@typespec/internal-build-utils"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/json-schema",
"comment": "`TypeScript` use `types` entry under `exports` of `package.json` instead of legacy `typesVersions` to provide the definition files",
"type": "none"
}
],
"packageName": "@typespec/json-schema"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/library-linter",
"comment": "`TypeScript` use `types` entry under `exports` of `package.json` instead of legacy `typesVersions` to provide the definition files",
"type": "none"
}
],
"packageName": "@typespec/library-linter"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/lint",
"comment": "`TypeScript` use `types` entry under `exports` of `package.json` instead of legacy `typesVersions` to provide the definition files",
"type": "none"
}
],
"packageName": "@typespec/lint"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/openapi",
"comment": "Add support for http status code ranges",
"type": "none"
}
],
"packageName": "@typespec/openapi"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/openapi",
"comment": "`TypeScript` use `types` entry under `exports` of `package.json` instead of legacy `typesVersions` to provide the definition files",
"type": "none"
}
],
"packageName": "@typespec/openapi"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/openapi3",
"comment": "Add support for http status code ranges",
"type": "none"
}
],
"packageName": "@typespec/openapi3"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/openapi3",
"comment": "`TypeScript` use `types` entry under `exports` of `package.json` instead of legacy `typesVersions` to provide the definition files",
"type": "none"
}
],
"packageName": "@typespec/openapi3"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/playground",
"comment": "",
"type": "none"
}
],
"packageName": "@typespec/playground"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/rest",
"comment": "`TypeScript` use `types` entry under `exports` of `package.json` instead of legacy `typesVersions` to provide the definition files",
"type": "none"
}
],
"packageName": "@typespec/rest"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/versioning",
"comment": "`TypeScript` use `types` entry under `exports` of `package.json` instead of legacy `typesVersions` to provide the definition files",
"type": "none"
}
],
"packageName": "@typespec/versioning"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "tmlanguage-generator",
"comment": "`TypeScript` use `types` entry under `exports` of `package.json` instead of legacy `typesVersions` to provide the definition files",
"type": "patch"
}
],
"packageName": "tmlanguage-generator"
}
10 changes: 10 additions & 0 deletions common/changes/typespec-vs/pkgjson-cleanup_2023-09-26-19-09.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "typespec-vs",
"comment": "`TypeScript` use `types` entry under `exports` of `package.json` instead of legacy `typesVersions` to provide the definition files",
"type": "none"
}
],
"packageName": "typespec-vs"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "typespec-vscode",
"comment": "`TypeScript` use `types` entry under `exports` of `package.json` instead of legacy `typesVersions` to provide the definition files",
"type": "none"
}
],
"packageName": "typespec-vscode"
}
5 changes: 4 additions & 1 deletion common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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": {
".": "./dist/src/index.js",
"./testing": "./dist/src/testing/index.js"
},
"typesVersions": {
"*": {
"*": ["./dist/src/index.d.ts"],
"testing": ["./dist/src/testing/index.d.ts"]
".": {
"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"
}
}
}
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/master/README.md",
"readme": "https://github.com/microsoft/typespec/blob/main/README.md",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions packages/bundler/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@typespec/bundler",
"version": "0.1.0-alpha.0",
"version": "0.1.0-alpha.1",
"author": "Microsoft Corporation",
"description": "Package to bundle a typespec library.",
"homepage": "https://microsoft.github.io/typespec",
"readme": "https://github.com/microsoft/typespec/blob/master/README.md",
"readme": "https://github.com/microsoft/typespec/blob/main/README.md",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
18 changes: 15 additions & 3 deletions packages/bundler/src/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ export interface TypeSpecBundleDefinition {
path: string;
main: string;
packageJson: PackageJson;
exports: Record<string, string>;
exports: Record<string, string | ExportData>;
}

export interface ExportData {
default: string;
types?: string;
}

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

const extraEntry = Object.fromEntries(
Object.entries(definition.exports).map(([key, value]) => {
return [key.replace("./", ""), normalizePath(resolve(libraryPath, value))];
return [
key.replace("./", ""),
normalizePath(resolve(libraryPath, getExportEntryPoint(value))),
];
})
);
return {
Expand Down Expand Up @@ -195,15 +203,19 @@ 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: definition.exports[basename(chunk.fileName)],
export: entry ? getExportEntryPoint(entry) : undefined,
};
}),
};
}

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
Loading

0 comments on commit 7454599

Please sign in to comment.