-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Bundling and make utils isomorphic
- Loading branch information
Showing
11 changed files
with
442 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import yaml from 'js-yaml'; | ||
|
||
export async function getYamlContent(fileURL: string, relativePath: string) { | ||
let fs = await import('node:fs'); | ||
let path = await import('node:path'); | ||
let { fileURLToPath } = await import('node:url'); | ||
let { dirname } = path; | ||
let fileURLPath = fileURLToPath(fileURL); | ||
let callerDirectoryName = dirname(fileURLPath); | ||
let yamlFilePath = path.resolve(callerDirectoryName, relativePath); | ||
let openapiDocument = yaml.load( | ||
fs.readFileSync(yamlFilePath, 'utf8') | ||
) as string; | ||
|
||
return openapiDocument; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,53 @@ | ||
// vite.config.js | ||
// import { fileURLToPath } from 'node:url'; | ||
|
||
import { defineConfig } from 'vite'; | ||
import { builtinModules } from 'module'; | ||
|
||
// let yamlLoader = fileURLToPath(new URL('src/load-yaml.ts', import.meta.url)); | ||
|
||
// import { nodeResolve } from '@rollup/plugin-node-resolve'; | ||
// import commonjs from '@rollup/plugin-commonjs'; | ||
|
||
export default defineConfig({ | ||
// plugins: [ | ||
// nodeResolve({ | ||
// // browser: true, | ||
// preferBuiltins: true, | ||
// }), | ||
// commonjs({ | ||
// preferBuiltins: true, | ||
// // browser: true, | ||
// }), | ||
// ], | ||
// plugins: [ | ||
// nodeResolve({ | ||
// preferBuiltins: true, | ||
// browser: false, | ||
// }), | ||
// commonjs(), | ||
// ], | ||
// resolve: { | ||
// preferBuiltins: true, | ||
// browser: false, | ||
// }, | ||
build: { | ||
target: 'esnext', | ||
ssr: true, | ||
outDir: 'build', | ||
// minify: false, | ||
lib: { | ||
entry: ['src/index.ts', 'src/openapi.ts'], | ||
formats: ['es'], | ||
fileName: (format, entryName) => `${entryName}.${format}.js`, | ||
types: 'src/index.d.ts', | ||
}, | ||
rollupOptions: { | ||
external: ['zod'], | ||
external: ['zod', ...builtinModules], | ||
}, | ||
}, | ||
// external: [/load\-yaml/], | ||
// optimizeDeps: { | ||
// include: ['@apidevtools/swagger-parser', 'js-yaml'], | ||
// }, | ||
}); |
Oops, something went wrong.