Skip to content

Commit

Permalink
fix(bytemd): svelte entry
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed Mar 25, 2022
1 parent 8d1e291 commit a0c8a31
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
*.log
.DS_Store
node_modules
dist
lib
dist/
svelte/
package-lock.json
tsconfig.tsbuildinfo
coverage
Expand Down
10 changes: 4 additions & 6 deletions norm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default defineConfig({
console.log('building helpers.js...')
await vite.build({
build: {
outDir: 'packages/bytemd/dist/svelte',
outDir: 'packages/bytemd/svelte',
lib: {
entry: 'packages/bytemd/src/helpers.ts',
formats: ['es'],
Expand All @@ -57,7 +57,7 @@ export default defineConfig({
await vite.build({
build: {
emptyOutDir: false,
outDir: 'packages/bytemd/dist/svelte',
outDir: 'packages/bytemd/svelte',
lib: {
entry: 'packages/bytemd/src/index.ts',
formats: ['es'],
Expand All @@ -73,12 +73,10 @@ export default defineConfig({
})

const files = await glob('packages/bytemd/src/*.svelte')
console.log(
'processing svelte files...' //files
)
console.log('processing svelte files...')

for (let file of files) {
const dest = file.replace('/src/', '/dist/svelte/')
const dest = file.replace('/src/', '/svelte/')
await fs.ensureDir(path.dirname(dest))

if (fs.statSync(file).isDirectory()) return
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"build": "norm build",
"dev": "norm",
"dev": "echo 'export * from \"../src/index\"' > packages/bytemd/svelte/index.js && norm",
"docs:build": "vitepress build docs",
"docs:dev": "vitepress dev docs",
"docs:serve": "vitepress serve docs",
Expand Down
7 changes: 3 additions & 4 deletions packages/bytemd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"types": "./dist/index.d.ts",
"files": [
"dist",
"locales"
"locales",
"svelte"
],
"dependencies": {
"@types/codemirror": "^5.60.5"
Expand All @@ -55,7 +56,5 @@
"vfile": "^5.3.2",
"word-count": "^0.2.2"
},
"publishConfig": {
"svelte": "./dist/svelte"
}
"svelte": "./svelte/index.js"
}
32 changes: 16 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion scripts/postinstall.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ libs.forEach((p) => {
// for compatible with old version
'./lib/locales/*': './locales/*',
}
pkg.files = ['dist', 'locales']

if (pkg.name === 'bytemd') {
pkg.exports['./dist/index.css'] = './dist/style.css'
pkg.exports['./dist/index.min.css'] = './dist/style.css'
pkg.files = ['dist', 'locales', 'svelte']
}
pkg.files = ['dist', 'locales']
fs.writeJsonSync(pkgPath, pkg)
})

Expand Down

0 comments on commit a0c8a31

Please sign in to comment.