Skip to content

Commit 7ea9822

Browse files
authored
Enables goto source/reference/implementation (#2334)
* feat: switch to exports field in package.json * chore: enables goto definition for the packages inside the mono-repo * fixes: npm warn config ignoring workspace config at samples/svelte-query/basic/.npmrc
1 parent b002e65 commit 7ea9822

33 files changed

+148
-68
lines changed

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*
22
!dist/**/*
33
!README.md
4-
!package.json
4+
!package.json
5+
dist/**/*.d.ts.map

packages/angular/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
"name": "@orval/angular",
33
"version": "7.11.2",
44
"license": "MIT",
5-
"main": "./dist/index.js",
6-
"types": "./dist/index.d.ts",
5+
"exports": {
6+
".": {
7+
"types": "./dist/index.d.ts",
8+
"default": "./dist/index.js"
9+
}
10+
},
711
"files": [
812
"dist"
913
],
1014
"scripts": {
11-
"build": "tsup --dts",
15+
"build": "tsup",
1216
"dev": "tsup --watch src",
1317
"lint": "eslint src/**/*.ts"
1418
},

packages/angular/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"extends": "../../tsconfig.base.json",
3-
"include": ["src/**/*.ts"]
3+
"include": ["src/**/*.ts"],
4+
"compilerOptions": {
5+
"outDir": "dist"
6+
}
47
}

packages/axios/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
"name": "@orval/axios",
33
"version": "7.11.2",
44
"license": "MIT",
5-
"main": "./dist/index.js",
6-
"types": "./dist/index.d.ts",
5+
"exports": {
6+
".": {
7+
"types": "./dist/index.d.ts",
8+
"default": "./dist/index.js"
9+
}
10+
},
711
"files": [
812
"dist"
913
],
1014
"scripts": {
11-
"build": "tsup --dts",
15+
"build": "tsup",
1216
"dev": "tsup --watch src",
1317
"lint": "eslint src/**/*.ts"
1418
},

packages/axios/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"extends": "../../tsconfig.base.json",
3-
"include": ["src/**/*.ts"]
3+
"include": ["src/**/*.ts"],
4+
"compilerOptions": {
5+
"outDir": "dist"
6+
}
47
}

packages/core/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
"name": "@orval/core",
33
"version": "7.11.2",
44
"license": "MIT",
5-
"main": "./dist/index.js",
6-
"types": "./dist/index.d.ts",
5+
"exports": {
6+
".": {
7+
"types": "./dist/index.d.ts",
8+
"default": "./dist/index.js"
9+
}
10+
},
711
"files": [
812
"dist"
913
],
1014
"scripts": {
11-
"build": "tsup --dts",
15+
"build": "tsup",
1216
"dev": "tsup --watch src",
1317
"lint": "eslint src/**/*.ts",
1418
"test": "vitest"

packages/core/src/generators/mutator.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import acorn, { Parser } from 'acorn';
1+
import { Parser, ecmaVersion } from 'acorn';
22
import chalk from 'chalk';
33
import fs from 'fs-extra';
44
import {
@@ -130,9 +130,7 @@ export const generateMutator = async ({
130130
}
131131
};
132132

133-
const getEcmaVersion = (
134-
target?: TsConfigTarget,
135-
): acorn.ecmaVersion | undefined => {
133+
const getEcmaVersion = (target?: TsConfigTarget): ecmaVersion | undefined => {
136134
if (!target) {
137135
return;
138136
}
@@ -142,7 +140,7 @@ const getEcmaVersion = (
142140
}
143141

144142
try {
145-
return Number(target.toLowerCase().replace('es', '')) as acorn.ecmaVersion;
143+
return Number(target.toLowerCase().replace('es', '')) as ecmaVersion;
146144
} catch {
147145
return;
148146
}
@@ -161,7 +159,7 @@ const removeComments = (file: string) => {
161159
const parseFile = (
162160
file: string,
163161
name: string,
164-
ecmaVersion: acorn.ecmaVersion = 6,
162+
ecmaVersion: ecmaVersion = 6,
165163
): GeneratorMutatorParsingInfo | undefined => {
166164
try {
167165
const ast = Parser.parse(file, { ecmaVersion }) as any;

packages/core/src/generators/schema-definition.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, expect, it } from 'vitest';
2-
import type { ContextSpecs, InputFiltersOption, SchemasObject } from '../types';
2+
import type { ContextSpecs, InputFiltersOption } from '../types';
3+
import type { SchemasObject } from 'openapi3-ts/oas30';
34
import { generateSchemasDefinition } from './schema-definition';
45

56
describe('generateSchemasDefinition', () => {

packages/core/src/utils/dynamic-import.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { pathToFileURL } from 'url';
1+
import { resolve, extname } from 'node:path';
2+
import { pathToFileURL } from 'node:url';
23
import { isModule, isObject, isString } from './assertion';
3-
import { resolve } from './path';
44

55
export const dynamicImport = async <T>(
66
toImport: T | string,
@@ -17,7 +17,10 @@ export const dynamicImport = async <T>(
1717
// use pathToFileURL to solve issue #1332.
1818
// https://github.com/nodejs/node/issues/31710
1919
const fileUrl = pathToFileURL(path);
20-
const data = await import(fileUrl.href);
20+
const isJson = extname(fileUrl.href) === '.json';
21+
const data = isJson
22+
? await import(fileUrl.href, { with: { type: 'json' } })
23+
: await import(fileUrl.href);
2124
if (takeDefault && (isObject(data) || isModule(data)) && data.default) {
2225
return (data as any).default as T;
2326
}

packages/core/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"extends": "../../tsconfig.base.json",
3-
"include": ["src/**/*.ts"]
3+
"include": ["src/**/*.ts"],
4+
"compilerOptions": {
5+
"outDir": "dist"
6+
}
47
}

0 commit comments

Comments
 (0)