@typed/vite-plugin 0.0.25 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/resolveTypedConfig.d.ts +7 -0
- package/dist/resolveTypedConfig.d.ts.map +1 -0
- package/dist/resolveTypedConfig.js +12 -0
- package/dist/resolveTypedConfig.js.map +1 -0
- package/dist/vite-plugin.d.ts +3 -55
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.js +102 -408
- package/dist/vite-plugin.js.map +1 -1
- package/package.json +6 -4
- package/src/constants.ts +1 -0
- package/src/index.ts +2 -0
- package/src/resolveTypedConfig.test.ts +40 -0
- package/src/resolveTypedConfig.ts +21 -0
- package/src/vite-plugin.ts +144 -640
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typed/vite-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@
|
|
24
|
+
"@fp-ts/core": "0.1.1",
|
|
25
|
+
"@typed/compiler": "0.0.22",
|
|
26
|
+
"@typed/framework": "0.0.18",
|
|
25
27
|
"fast-glob": "^3.2.12",
|
|
26
28
|
"vavite": "^1.5.3",
|
|
27
29
|
"vite": "^4.0.4",
|
|
@@ -29,13 +31,13 @@
|
|
|
29
31
|
"vite-tsconfig-paths": "^4.0.5"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
32
|
-
"@effect/language-service": "^0.0.
|
|
34
|
+
"@effect/language-service": "^0.0.17",
|
|
33
35
|
"ts-morph": "^17.0.1"
|
|
34
36
|
},
|
|
35
37
|
"peerDependencies": {
|
|
36
38
|
"vite-node": "^0.27.2"
|
|
37
39
|
},
|
|
38
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "13a5ec0fe1b8bf1365a2010415927bebbdd7d320",
|
|
39
41
|
"publishConfig": {
|
|
40
42
|
"access": "public"
|
|
41
43
|
},
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PLUGIN_NAME = '@typed/vite-plugin'
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { deepStrictEqual, ok } from 'assert'
|
|
2
|
+
import { dirname, join } from 'path'
|
|
3
|
+
import { fileURLToPath } from 'url'
|
|
4
|
+
|
|
5
|
+
import { isSome, some } from '@fp-ts/core/Option'
|
|
6
|
+
import { describe, it } from 'vitest'
|
|
7
|
+
|
|
8
|
+
import { resolveTypedConfig } from './resolveTypedConfig.js'
|
|
9
|
+
import type { ResolvedOptions } from './vite-plugin.js'
|
|
10
|
+
|
|
11
|
+
const vitePluginSrcDirectory = dirname(fileURLToPath(import.meta.url))
|
|
12
|
+
const rootDirectory = dirname(dirname(dirname(vitePluginSrcDirectory)))
|
|
13
|
+
const sourceDirectory = join(rootDirectory, 'example')
|
|
14
|
+
|
|
15
|
+
describe(import.meta.url, () => {
|
|
16
|
+
it(
|
|
17
|
+
'resolves typed config',
|
|
18
|
+
async () => {
|
|
19
|
+
const config = await resolveTypedConfig({}, 'build', 'production')
|
|
20
|
+
const expected: ResolvedOptions = {
|
|
21
|
+
sourceDirectory,
|
|
22
|
+
tsConfig: join(sourceDirectory, 'tsconfig.json'),
|
|
23
|
+
serverFilePath: some(join(sourceDirectory, 'server.ts')),
|
|
24
|
+
clientOutputDirectory: join(sourceDirectory, 'dist/client'),
|
|
25
|
+
serverOutputDirectory: join(sourceDirectory, 'dist/server'),
|
|
26
|
+
htmlFiles: [join(sourceDirectory, 'index.html'), join(sourceDirectory, 'other.html')],
|
|
27
|
+
debug: false,
|
|
28
|
+
saveGeneratedModules: true,
|
|
29
|
+
isStaticBuild: false,
|
|
30
|
+
base: '/',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
ok(isSome(config))
|
|
34
|
+
deepStrictEqual(config.value, expected)
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
timeout: 10_000,
|
|
38
|
+
},
|
|
39
|
+
)
|
|
40
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { none, some, type Option } from '@fp-ts/core/Option'
|
|
2
|
+
import type { ResolvedOptions } from '@typed/compiler'
|
|
3
|
+
import { resolveConfig } from 'vite'
|
|
4
|
+
|
|
5
|
+
import { PLUGIN_NAME } from './constants.js'
|
|
6
|
+
import type { TypedVitePlugin } from './vite-plugin.js'
|
|
7
|
+
|
|
8
|
+
export async function resolveTypedConfig(
|
|
9
|
+
...args: ArgsOf<typeof resolveConfig>
|
|
10
|
+
): Promise<Option<ResolvedOptions>> {
|
|
11
|
+
const config = await resolveConfig(...args)
|
|
12
|
+
const typedPlugin = config.plugins.find((p): p is TypedVitePlugin => p.name === PLUGIN_NAME)
|
|
13
|
+
|
|
14
|
+
if (!typedPlugin) {
|
|
15
|
+
return none()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return some(typedPlugin.resolvedOptions)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type ArgsOf<T> = T extends (...args: infer A) => any ? A : never
|