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

feat: add dts plugin #359

Merged
merged 70 commits into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
ae3ad95
chore: prepare ts-morph generate dts config
ErKeLost May 16, 2023
0e4ce6c
chore: remove dts deps
ErKeLost May 17, 2023
dad55d8
Merge remote-tracking branch 'upstream/main' into build/dts
ErKeLost May 17, 2023
472f115
feat: add dts plugins
ErKeLost May 17, 2023
66e7073
chore: emit js plugin with example
ErKeLost May 17, 2023
4cf1ce7
chore: test ts-morph
ErKeLost May 17, 2023
a26443c
feat: add dts plugins
ErKeLost May 18, 2023
e6c9df2
chore: add test resolve error
ErKeLost May 18, 2023
abaa277
Merge branch 'main' of github.com:farm-fe/farm into build/dts
ErKeLost May 29, 2023
e63ce4b
chore: update lock
ErKeLost May 29, 2023
a9877c0
chore: example
ErKeLost May 29, 2023
30c5abd
chore: import ts-morph scope
ErKeLost May 30, 2023
661913c
chore: resolve dts example
ErKeLost May 30, 2023
4f61f54
Merge branch 'main' into build/dts
ErKeLost May 31, 2023
8df00ba
Merge branch 'main' of github.com:farm-fe/farm into build/dts
ErKeLost Jun 1, 2023
a01cfb3
Merge branch 'build/dts' of github.com:ErKeLost/farm into build/dts
ErKeLost Jun 1, 2023
f017067
chore: test generate dts file
ErKeLost Jun 1, 2023
54d1187
chore: success generate dts files
ErKeLost Jun 1, 2023
d2f3ab6
Merge branch 'main' into build/dts
ErKeLost Jun 1, 2023
a817967
Merge branch 'main' of github.com:farm-fe/farm into build/dts
ErKeLost Jun 1, 2023
31319e5
Merge branch 'build/dts' of github.com:ErKeLost/farm into build/dts
ErKeLost Jun 1, 2023
54525b8
Merge branch 'main' into build/dts
ErKeLost Jun 2, 2023
19b66ae
Merge branch 'build/dts' of github.com:ErKeLost/farm; branch 'main' o…
ErKeLost Jun 2, 2023
df825c4
chore: use farm
ErKeLost Jun 2, 2023
5375bf3
chore: update scripts
ErKeLost Jun 2, 2023
1c0e6fe
chore: package
ErKeLost Jun 3, 2023
63be613
Merge branch 'main' of github.com:farm-fe/farm into build/dts
ErKeLost Jun 5, 2023
6580ab2
chore: emit sources
ErKeLost Jun 5, 2023
ef2b19e
Merge branch 'main' of github.com:farm-fe/farm into build/dts
ErKeLost Jun 7, 2023
c252c47
Merge branch 'build/dts' of github.com:ErKeLost/farm into build/dts
ErKeLost Jun 7, 2023
91ecba7
chore: test dts plugins
ErKeLost Jun 7, 2023
58228a7
chore: update dts
ErKeLost Jun 7, 2023
eeb6f45
Merge branch 'main' of github.com:farm-fe/farm into build/dts
ErKeLost Jul 23, 2023
d88f6c3
Merge branch 'main' of github.com:farm-fe/farm into build/dts
ErKeLost Aug 5, 2023
7ace103
chore: binding code
ErKeLost Aug 5, 2023
483cbf8
chore: dts generate
ErKeLost Aug 5, 2023
a200478
chore: update dts file
ErKeLost Aug 6, 2023
592264d
chore: update dts file
ErKeLost Aug 6, 2023
76e593a
fix: path.indexof is not a function error
ErKeLost Aug 6, 2023
bb4c1fe
chore: update type js
ErKeLost Aug 6, 2023
36a57d1
chore: update type js
ErKeLost Aug 6, 2023
baa4d53
Merge branch 'farm-fe:main' into build/dts
ErKeLost Aug 8, 2023
177fa85
chore: test example
ErKeLost Aug 8, 2023
666e6e4
refactor: plugins
ErKeLost Aug 8, 2023
e69bcc3
chore: update config
ErKeLost Aug 8, 2023
b6026df
Merge branch 'main' of github.com:farm-fe/farm into build/dts
ErKeLost Aug 13, 2023
3337e1f
chore: update dts plugin
ErKeLost Aug 13, 2023
82f9cf7
chore: update ts plugins
ErKeLost Aug 13, 2023
68f1ba6
chore: update dts plugins
ErKeLost Aug 14, 2023
2ce1ad4
chore: update dts file
ErKeLost Aug 14, 2023
5fd7581
chore: update code
ErKeLost Aug 16, 2023
d6a6e17
chore: js plugin support finish hook (#513)
wre232114 Aug 18, 2023
7cc248d
chore: update dts plugins
ErKeLost Aug 18, 2023
ed0966f
chore: update dts plugins
ErKeLost Aug 18, 2023
338d17a
chore: update dts plugins
ErKeLost Aug 18, 2023
11baaa1
chore: update dts plugins
ErKeLost Aug 19, 2023
7ca258f
Merge branch 'main' into build/dts
ErKeLost Aug 19, 2023
1b7f1b1
Merge branch 'build/dts' of github.com:ErKeLost/farm into build/dts
ErKeLost Aug 19, 2023
c9ddee1
chore: update vue plugins type
ErKeLost Aug 19, 2023
35947a5
chore: update vue plugins type
ErKeLost Aug 19, 2023
6bf5e61
chore: update plugins
ErKeLost Aug 19, 2023
3eda2eb
chore: update dts plugins
ErKeLost Aug 19, 2023
8356d25
chore: update dts plugins
ErKeLost Aug 19, 2023
2ea1467
chore: update dts plugins
ErKeLost Aug 19, 2023
f6ca4f3
chore: update dts plugins
ErKeLost Aug 19, 2023
ee05922
chore: update type
ErKeLost Aug 19, 2023
10210c9
Merge branch 'main' into build/dts
ErKeLost Aug 20, 2023
f49415b
chore: update dts
ErKeLost Aug 20, 2023
300c3b8
Merge branches 'build/dts' and 'build/dts' of github.com:ErKeLost/far…
ErKeLost Aug 20, 2023
f506c3a
Merge branch 'main' into build/dts
ErKeLost Aug 20, 2023
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
5 changes: 5 additions & 0 deletions .changeset/eighty-bobcats-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@farmfe/js-plugin-dts': patch
---

feat: add dts plugins with farm
2 changes: 2 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"egui",
"elems",
"esbuild",
"importee",
"execa",
"farmfe",
"Fock",
Expand All @@ -41,6 +42,7 @@
"hasher",
"idents",
"jridgewell",
"kolorist",
"libfarmfe",
"libloading",
"loglevel",
Expand Down
39 changes: 39 additions & 0 deletions examples/generate-dts/farm.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import farmDtsPlugin from '@farmfe/js-plugin-dts';
import { builtinModules } from 'module';

/**
* @type {import('@farmfe/core').UserConfig}
*/
export default {
compilation: {
input: {
index: 'src/index.ts'
},
output: {
path: 'dist',
targetEnv: 'node'
},
external: [
...builtinModules.map((m) => `^${m}$`),
...builtinModules.map((m) => `^node:${m}$`)
],
partialBundling: {
moduleBuckets: [
{
name: 'node.bundle.js',
test: ['.+']
}
]
},
minify: false,
sourcemap: false,
presetEnv: false,
treeShaking: true
},
server: {
hmr: false
},
plugins: [farmDtsPlugin({
outputDir: 'build'
})]
};
14 changes: 14 additions & 0 deletions examples/generate-dts/generate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
interface IExample {
name: string;
age: number;
obj: any;
}

export const example: IExample = {
name: 'test',
age: 1,
obj: {
a: 1,
b: 2
}
};
14 changes: 14 additions & 0 deletions examples/generate-dts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { example } from './generate';
import type { myTuple } from './type';
interface obj {
name: string;
age: number;
}
const res: myTuple = [1, 2, 3, '4'];
export const obj: obj = {
name: 'erkelost',
age: 18
};
console.log(obj);
console.log(example, obj, res);
export type { User } from './types';
16 changes: 16 additions & 0 deletions examples/generate-dts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "ts",
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"@farmfe/cli": "workspace:*",
"@farmfe/core": "workspace:*",
"@farmfe/js-plugin-dts": "workspace:*",
"ts-morph": "^18.0.0"
},
"scripts": {
"build": "farm build",
"build:ts": "tsc"
}
}
1 change: 1 addition & 0 deletions examples/generate-dts/src/bbb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const a: string = 'erkelost';
7 changes: 7 additions & 0 deletions examples/generate-dts/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { TestBase } from './test';
import { a } from './bbb';
console.log(a);

export interface Test extends TestBase {
count: number;
}
22 changes: 22 additions & 0 deletions examples/generate-dts/src/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export interface TestBase {
name: string;
}

export interface Component {
name: string;
type: string;
}

export const test: TestBase = {
name: 'test'
};

export const CONSTANT = ['one', 'two'] as const;

export interface WithConstant {
constant: typeof CONSTANT[number];
}

export function method(arg: string) {
console.log(arg);
}
22 changes: 22 additions & 0 deletions examples/generate-dts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// "extends": "../../tsconfig.base.json",
"exclude": ["node_modules"],
"include": ["index.ts"],
"compilerOptions": {
"noUnusedParameters": false,
"noUnusedLocals": false,
"outDir": "dist",
"lib": ["DOM", "ESNext"],
"noImplicitAny": true,
"sourceMap": true,
"target": "es2020",
"module": "node16",
"moduleResolution": "node16",
"declaration": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"skipDefaultLibCheck": true,
"skipLibCheck": true,
"resolveJsonModule": true
}
}
3 changes: 3 additions & 0 deletions examples/generate-dts/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type myTuple = [number, number, number?, string?];
const s: [string, string, boolean] = ['a', 'b', true];
export { s };
4 changes: 4 additions & 0 deletions examples/generate-dts/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface User {
id: string,
name: string
}
4 changes: 2 additions & 2 deletions examples/react/farm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export default defineConfig({
prefixer: {
targets: ['last 2 versions', 'Firefox ESR', '> 1%', 'ie >= 11']
}
}
},
// treeShaking: true,
// minify: true,
minify: false,
},
server: {
hmr: true,
Expand Down
2 changes: 0 additions & 2 deletions examples/vue/src/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

<script lang="ts" setup>
import Welcome from './components/Welcome.vue';
import axios from 'axios';
console.log(axios.create);
fetch('/api')
.then((response) => response.json())
.then((json) => console.log(json));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import { builtinModules } from 'module';
*/
export default {
compilation: {
minify: false,
presetEnv: false,
input: {
index: './src/index.ts'
},
output: {
entryFilename: '[entryName].cjs',
targetEnv: 'node',
format: 'cjs'
path: 'build',
filename: 'index.[ext]',
targetEnv: 'node'
},
external: [
...builtinModules.map((m) => `^${m}$`),
Expand All @@ -22,11 +20,15 @@ export default {
partialBundling: {
moduleBuckets: [
{
name: 'index.js',
name: 'node.bundle.js',
test: ['.+']
}
]
}
},
minify: false,
sourcemap: false,
presetEnv: false,
treeShaking: false
},
server: {
hmr: false
Expand Down
30 changes: 30 additions & 0 deletions js-plugins/dts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@farmfe/js-plugin-dts",
"version": "0.1.0",
"description": "",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module",
"scripts": {
"build": "tsc -p ./tsconfig.build.json",
"build:farm": "farm build",
"start": "pnpm run build -w",
"watch": "farm watch",
"prepublishOnly": "npm run build",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"fast-glob": "^3.2.12",
"fs-extra": "^11.1.1",
"kolorist": "^1.8.0",
"ts-morph": "^19.0.0"
},
"devDependencies": {
"@farmfe/cli": "workspace:*",
"@farmfe/core": "workspace:*",
"@types/fs-extra": "^11.0.1"
}
}
Loading
Loading