Skip to content

Commit

Permalink
fix: nuxt module
Browse files Browse the repository at this point in the history
  • Loading branch information
productdevbook committed Nov 30, 2024
1 parent f7b6d98 commit b17df1e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
18 changes: 10 additions & 8 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,22 @@
"default": "./dist/nuxt/index.cjs"
}
},
"./contast": {
"import": {
"types": "./dist/constant.d.mts",
"default": "./dist/constant.mjs"
}
},
"./resolver": {
"import": {
"types": "./dist/resolver/index.d.mts",
"default": "./dist/resolver/index.mjs"
},
"require": {
"types": "./dist/resolver/index.d.cts",
"default": "./dist/resolver/index.cjs"
}
},
"./namespaced": {
"import": {
"types": "./dist/namespaced/index.d.mts",
"default": "./dist/namespaced/index.mjs"
},
"require": {
"types": "./dist/namespaced/index.d.cts",
"default": "./dist/namespaced/index.cjs"
}
}
},
Expand All @@ -73,6 +71,10 @@
"namespaced": [
"./dist/namespaced/index.d.mts",
"./dist/namespaced/index.d.ts"
],
"constant": [
"./dist/constant.d.mts",
"./dist/constant.d.ts"
]
}
},
Expand Down
29 changes: 21 additions & 8 deletions packages/core/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { execSync } from 'node:child_process'
import { resolve } from 'node:path'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
Expand All @@ -22,6 +23,13 @@ export default defineConfig({
tsconfigPath: 'tsconfig.build.json',
exclude: ['src/test/**', 'src/**/stories/**', 'src/**/*.stories.vue'],
rollupTypes: true,
afterBuild: async () => {
console.log('dts afterBuild')
// pnpm build:plugins
execSync('pnpm build:plugins', { stdio: 'inherit', cwd: resolve(__dirname, '../plugins') })
execSync('pnpm generate:plugins', { stdio: 'inherit', cwd: resolve(__dirname, '../plugins') })
execSync('pnpm lint:fix', { stdio: 'inherit', cwd: resolve(__dirname, '../..') })
},
}),
],
resolve: {
Expand All @@ -37,9 +45,10 @@ export default defineConfig({
lib: {
name: 'oku-ui-primitives',
formats: ['es'],
fileName: (_, name) => `${name}.mjs`,
fileName: (format, entryName) => `${entryName}.mjs`,
entry: {
index: resolve(__dirname, 'src/index.ts'),
constant: resolve(__dirname, 'src/constant/index.ts'),
},
},
rollupOptions: {
Expand All @@ -48,18 +57,22 @@ export default defineConfig({
...Object.keys(pkg.peerDependencies ?? {}),
],
output: {
manualChunks: (id) => {
// Daha basit chunk stratejisi
const chunks = id.match(/[/\\]src[/\\](.*?)[/\\]/)
return chunks ? chunks[1] : null
manualChunks(id) {
if (id.includes('node_modules')) {
// vendor kodlarını gruplayalım
return 'vendor'
}
// src altındaki ana klasörleri ayrı chunk'lara bölelim
const match = id.match(/[/\\]src[/\\](.*?)[/\\]/)
if (match && match[1]) {
return match[1]
}
},
exports: 'named',
chunkFileNames: '[name].mjs',
assetFileNames: 'index.css',
hoistTransitiveImports: false,
hoistTransitiveImports: true,
minifyInternalExports: true,
},
},

},
})
4 changes: 2 additions & 2 deletions packages/plugins/src/namespaced/generate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Components } from '@oku-ui/primitives/constant'
import type { Components } from '../../../core/src/constant'
import { writeFileSync } from 'node:fs'
import { components } from '@oku-ui/primitives/constant'
import { components } from '../../../core/src/constant'

const excludedComponent = ['primitive', 'visuallyHidden']
const filteredComponent = Object.keys(components).filter(i => !excludedComponent.includes(i)) as Components[]
Expand Down

0 comments on commit b17df1e

Please sign in to comment.