Skip to content

Commit

Permalink
feat: add CJS build
Browse files Browse the repository at this point in the history
  • Loading branch information
KermanX committed Oct 25, 2024
1 parent cbfdd79 commit 60c0504
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 147 deletions.
9 changes: 3 additions & 6 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
"import": "./src/index.ts"
}
},
"main": "./src/index.ts",
"types": "./src/index.ts",
"files": [
"README.md",
"dist"
Expand All @@ -55,10 +53,9 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts"
}
}
}
82 changes: 41 additions & 41 deletions packages/core/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import { defineConfig } from 'vite'
import Dts from 'vite-plugin-dts'

export default defineConfig({
plugins: [
{
name: 'replace dev flag',
enforce: 'pre',
transform: {
order: 'pre',
handler(code, id) {
if (id.endsWith('.ts'))
return code.replaceAll(`__DEV__`, `!!(process.env.NODE_ENV !== "production")`)
},
},
},
Dts({
include: [
'./src/**/*.ts',
'./tsconfig.json',
'./shim.d.ts',
],
rollupTypes: true,
beforeWriteFile(_, content) {
return {
content: content.replaceAll('\'@vue/reactivity\'', '\'@reactive-vscode/reactivity\''),
}
},
}),
],
build: {
lib: {
entry: 'src/index.ts',
formats: ['es'],
fileName: 'index',
},
rollupOptions: {
external: ['vscode', '@reactive-vscode/reactivity'],
},
},
})
import { defineConfig } from 'vite'
import Dts from 'vite-plugin-dts'

export default defineConfig({
plugins: [
{
name: 'replace dev flag',
enforce: 'pre',
transform: {
order: 'pre',
handler(code, id) {
if (id.endsWith('.ts'))
return code.replaceAll(`__DEV__`, `!!(process.env.NODE_ENV !== "production")`)
},
},
},
Dts({
include: [
'./src/**/*.ts',
'./tsconfig.json',
'./shim.d.ts',
],
rollupTypes: true,
beforeWriteFile(_, content) {
return {
content: content.replaceAll('\'@vue/reactivity\'', '\'@reactive-vscode/reactivity\''),
}
},
}),
],
build: {
lib: {
entry: 'src/index.ts',
formats: ['es', 'cjs'],
fileName: 'index',
},
rollupOptions: {
external: ['vscode', '@reactive-vscode/reactivity'],
},
},
})
9 changes: 3 additions & 6 deletions packages/reactivity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"import": "./src/index.ts"
}
},
"main": "./src/index.ts",
"types": "./src/index.ts",
"files": [
"README.md",
"dist"
Expand All @@ -44,10 +42,9 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts"
}
}
}
71 changes: 35 additions & 36 deletions packages/reactivity/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
import path from 'node:path'
import { defineConfig } from 'vite'
import Dts from 'vite-plugin-dts'

export default defineConfig({
plugins: [
{
name: 'replace dev flag',
enforce: 'pre',
transform: {
order: 'pre',
handler(code, id) {
if (id.endsWith('.ts'))
return code.replaceAll(`__DEV__`, `!!(process.env.NODE_ENV !== "production")`)
},
},
},
Dts({
include: [
'./src/**/*.ts',
'./tsconfig.json',
'./shim.d.ts',
],
rollupTypes: true,
bundledPackages: ['@vue/reactivity', '@vue/shared'],
}),
],
build: {
lib: {
entry: 'src/index.ts',
formats: ['es'],
fileName: 'index',
},
minify: false,
},
})
import { defineConfig } from 'vite'
import Dts from 'vite-plugin-dts'

export default defineConfig({
plugins: [
{
name: 'replace dev flag',
enforce: 'pre',
transform: {
order: 'pre',
handler(code, id) {
if (id.endsWith('.ts'))
return code.replaceAll(`__DEV__`, `!!(process.env.NODE_ENV !== "production")`)
},
},
},
Dts({
include: [
'./src/**/*.ts',
'./tsconfig.json',
'./shim.d.ts',
],
rollupTypes: true,
bundledPackages: ['@vue/reactivity', '@vue/shared'],
}),
],
build: {
lib: {
entry: 'src/index.ts',
formats: ['es', 'cjs'],
fileName: 'index',
},
minify: false,
},
})
9 changes: 3 additions & 6 deletions packages/vueuse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"import": "./src/index.ts"
}
},
"main": "./src/index.ts",
"types": "./src/index.ts",
"files": [
"README.md",
"dist",
Expand All @@ -50,10 +48,9 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts"
}
}
}
104 changes: 52 additions & 52 deletions packages/vueuse/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
import path from 'node:path'
import { defineConfig } from 'vite'
import Dts from 'vite-plugin-dts'

export default defineConfig({
plugins: [
{
name: 'replace constants',
enforce: 'pre',
transform: {
order: 'pre',
handler(code, id) {
if (id.endsWith('.mjs')) {
return code
.replaceAll(`getCurrentInstance()`, `null`)
.replaceAll(`getLifeCycleTarget()`, `null`)
}
},
},
},
Dts({
include: [
'./src/**/*.ts',
'./tsconfig.json',
'./shim.d.ts',
],
rollupTypes: true,
bundledPackages: ['@vueuse/core', '@vueuse/shared'],
beforeWriteFile(_, content) {
return {
content: content.replaceAll('\'vue-demi\'', '\'@reactive-vscode/reactivity\''),
}
},
}),
],
resolve: {
alias: {
'vue-demi': path.resolve(__dirname, './src/vue-demi.ts'),
},
},
build: {
lib: {
entry: 'src/index.ts',
formats: ['es'],
fileName: 'index',
},
rollupOptions: {
external: ['@reactive-vscode/reactivity'],
},
minify: false,
},
})
import path from 'node:path'
import { defineConfig } from 'vite'
import Dts from 'vite-plugin-dts'

export default defineConfig({
plugins: [
{
name: 'replace constants',
enforce: 'pre',
transform: {
order: 'pre',
handler(code, id) {
if (id.endsWith('.mjs')) {
return code
.replaceAll(`getCurrentInstance()`, `null`)
.replaceAll(`getLifeCycleTarget()`, `null`)
}
},
},
},
Dts({
include: [
'./src/**/*.ts',
'./tsconfig.json',
'./shim.d.ts',
],
rollupTypes: true,
bundledPackages: ['@vueuse/core', '@vueuse/shared'],
beforeWriteFile(_, content) {
return {
content: content.replaceAll('\'vue-demi\'', '\'@reactive-vscode/reactivity\''),
}
},
}),
],
resolve: {
alias: {
'vue-demi': path.resolve(__dirname, './src/vue-demi.ts'),
},
},
build: {
lib: {
entry: 'src/index.ts',
formats: ['es', 'cjs'],
fileName: 'index',
},
rollupOptions: {
external: ['@reactive-vscode/reactivity'],
},
minify: false,
},
})

0 comments on commit 60c0504

Please sign in to comment.