Skip to content

Commit

Permalink
wip on fixing treeshaking
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtSuslov committed Aug 29, 2023
1 parent 1b25eb5 commit 0cd21f4
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 26 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@
"typescript": "^5.0.4",
"yorkie": "^2.0.0"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"resolutions": {
"defaino": "portal:/Users/art/Workspace/lbp-tokene"
}
}
3 changes: 2 additions & 1 deletion packages/toasts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"default": "./dist/index.js"
},
"./dist/index.css": {
"default": "./dist/index.css"
"default": "./dist/style.css"
},
"./*": "./*"
},
Expand Down Expand Up @@ -84,6 +84,7 @@
"eslint-plugin-vue": "^9.11.0",
"eslint-plugin-vue-i18n": "^0.3.0",
"jest": "^29.5.0",
"rollup-plugin-pure": "^0.1.1",
"tsc-alias": "^1.8.2",
"vite": "^4.3.3",
"vite-svg-loader": "^4.0.0",
Expand Down
27 changes: 19 additions & 8 deletions packages/toasts/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
import typescript from '@rollup/plugin-typescript'
import vue from '@vitejs/plugin-vue'
import * as path from 'path'
import { defineConfig } from 'vite'
// import svgLoader from 'vite-svg-loader'
import { PluginPure } from 'rollup-plugin-pure'
import { defineConfig } from 'vite'

export default defineConfig({
build: {
cssCodeSplit: true,
cssCodeSplit: false,
cssMinify: 'esbuild',
sourcemap: true,
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'index',
formats: ['es', 'cjs', 'iife'],
fileName: format =>
format === 'iife' ? 'index.js' : `${format}/index.js`,
formats: ['es'],
fileName: (format, entryName) => {
console.log(format, entryName)
return format === 'iife' ? 'index.js' : `${format}/index.js`
},
},
rollupOptions: {
input: {
index: path.resolve(__dirname, 'src/index.ts'),
},
external: ['vue', '@vueuse/core'],
output: {
assetFileNames: assetInfo => {
return assetInfo.name!
},
assetFileNames: assetInfo => assetInfo.name!,
exports: 'named',
globals: {
vue: 'vue',
},
// inlineDynamicImports: false,
// esModule: true,
preserveModules: true,
},
},
},
Expand Down Expand Up @@ -66,5 +71,11 @@ export default defineConfig({
}),
vue(),
// svgLoader(),
PluginPure({
functions: ['defineComponent'],
include: [/(?<!im)pure\.js$/],
// exclude: [],
// sourcemap: true,
}),
],
})
2 changes: 1 addition & 1 deletion packages/toasts/web-types.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"framework": "vue",
"name": "@tokene/toasts",
"version": "0.0.0-rc.17",
"version": "0.0.0-rc.18",
"contributions": {
"html": {
"description-markup": "markdown",
Expand Down
4 changes: 3 additions & 1 deletion packages/ui-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"default": "./dist/index.js"
},
"./dist/index.css": {
"default": "./dist/index.css"
"default": "./dist/style.css"
},
"./*": "./*"
},
Expand Down Expand Up @@ -97,8 +97,10 @@
"eslint-plugin-vue": "^9.11.0",
"eslint-plugin-vue-i18n": "^0.3.0",
"jest": "^29.5.0",
"rollup-plugin-pure": "^0.1.1",
"tsc-alias": "^1.8.2",
"vite": "^4.3.3",
"vite-plugin-components": "^0.13.3",
"vite-plugin-static-copy": "^0.14.0",
"vite-plugin-svg-icons": "^2.0.1",
"vite-svg-loader": "^4.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/ui-kit/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import '@tokene/styles/src/index.scss'

export * from './common'
export * from './enums'
export * from './fields'
export * as Common from './common'
export * as Enums from './enums'
export * as Fields from './fields'
35 changes: 28 additions & 7 deletions packages/ui-kit/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import typescript from '@rollup/plugin-typescript'
import vue from '@vitejs/plugin-vue'
import * as path from 'path'
import { PluginPure } from 'rollup-plugin-pure'
import { defineConfig, loadEnv } from 'vite'
import ViteComponents from 'vite-plugin-components'
// import { viteStaticCopy } from 'vite-plugin-static-copy'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import svgLoader from 'vite-svg-loader'
Expand All @@ -13,14 +15,14 @@ export default defineConfig(({ mode }) => {

return {
build: {
cssCodeSplit: true,
cssCodeSplit: false,
cssMinify: 'esbuild',
sourcemap: true,
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'index',
formats: ['es', 'cjs', 'iife'],
fileName: format =>
format === 'iife' ? 'index.js' : `${format}/index.js`,
formats: ['es'],
// fileName: (format, entryName) => `${format}/${entryName}.js`,
},
rollupOptions: {
input: {
Expand All @@ -34,13 +36,19 @@ export default defineConfig(({ mode }) => {
'@vueuse/core',
],
output: {
assetFileNames: assetInfo => {
return assetInfo.name!
},
// assetFileNames: assetInfo => {
// return assetInfo.name!
// },
exports: 'named',
globals: {
vue: 'vue',
},
inlineDynamicImports: false,
preserveModules: true,
// preserveSymlinks: false,
// shimMissingExports: false,
// strictDeprecations: true,
// treeshake: 'safest',
},
},
},
Expand Down Expand Up @@ -99,6 +107,19 @@ export default defineConfig(({ mode }) => {
// ],
// }),
svgLoader(),
// PluginPure({
// functions: ['defineComponent'],
// include: [/(?<!im)pure\.js$/],
// // exclude: [],
// // sourcemap: true,
// }),
ViteComponents({
// Configure Vite Components plugin
// Use array of directories where your components are located
dirs: ['src'],
deep: true, // Allow subdirectories to be scanned
extensions: ['vue'], // Specify file extensions to search for
}),
],
}
})
2 changes: 1 addition & 1 deletion packages/ui-kit/web-types.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"framework": "vue",
"name": "@tokene/ui-kit",
"version": "0.0.0-rc.17",
"version": "0.0.0-rc.18",
"contributions": {
"html": {
"description-markup": "markdown",
Expand Down
61 changes: 58 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3372,7 +3372,7 @@ __metadata:
languageName: node
linkType: hard

"@rollup/pluginutils@npm:^3 || ^4 || ^5, @rollup/pluginutils@npm:^5.0.1":
"@rollup/pluginutils@npm:^3 || ^4 || ^5, @rollup/pluginutils@npm:^5.0.1, @rollup/pluginutils@npm:^5.0.2":
version: 5.0.2
resolution: "@rollup/pluginutils@npm:5.0.2"
dependencies:
Expand Down Expand Up @@ -3711,6 +3711,7 @@ __metadata:
eslint-plugin-vue-i18n: ^0.3.0
jest: ^29.5.0
lodash: ^4.17.21
rollup-plugin-pure: ^0.1.1
tsc-alias: ^1.8.2
vite: ^4.3.3
vite-svg-loader: ^4.0.0
Expand Down Expand Up @@ -3802,8 +3803,10 @@ __metadata:
jest: ^29.5.0
lodash: ^4.17.21
loglevel: ^1.8.1
rollup-plugin-pure: ^0.1.1
tsc-alias: ^1.8.2
vite: ^4.3.3
vite-plugin-components: ^0.13.3
vite-plugin-static-copy: ^0.14.0
vite-plugin-svg-icons: ^2.0.1
vite-svg-loader: ^4.0.0
Expand Down Expand Up @@ -4785,7 +4788,7 @@ __metadata:
languageName: node
linkType: hard

"acorn@npm:^8.8.2, acorn@npm:^8.9.0":
"acorn@npm:^8.10.0, acorn@npm:^8.8.2, acorn@npm:^8.9.0":
version: 8.10.0
resolution: "acorn@npm:8.10.0"
bin:
Expand Down Expand Up @@ -7811,7 +7814,7 @@ __metadata:
languageName: node
linkType: hard

"fast-glob@npm:^3.2.11, fast-glob@npm:^3.2.5, fast-glob@npm:^3.2.9":
"fast-glob@npm:^3.2.11, fast-glob@npm:^3.2.5, fast-glob@npm:^3.2.7, fast-glob@npm:^3.2.9":
version: 3.3.1
resolution: "fast-glob@npm:3.3.1"
dependencies:
Expand Down Expand Up @@ -10815,6 +10818,15 @@ __metadata:
languageName: node
linkType: hard

"magic-string@npm:^0.25.7":
version: 0.25.9
resolution: "magic-string@npm:0.25.9"
dependencies:
sourcemap-codec: ^1.4.8
checksum: 9a0e55a15c7303fc360f9572a71cffba1f61451bc92c5602b1206c9d17f492403bf96f946dfce7483e66822d6b74607262e24392e87b0ac27b786e69a40e9b1a
languageName: node
linkType: hard

"magic-string@npm:^0.27.0":
version: 0.27.0
resolution: "magic-string@npm:0.27.0"
Expand Down Expand Up @@ -12762,6 +12774,19 @@ __metadata:
languageName: node
linkType: hard

"rollup-plugin-pure@npm:^0.1.1":
version: 0.1.1
resolution: "rollup-plugin-pure@npm:0.1.1"
dependencies:
"@rollup/pluginutils": ^5.0.2
magic-string: ^0.30.0
strip-literal: ^1.0.1
peerDependencies:
rollup: ^3.0.0
checksum: 4a56047081f04369c3559f5b093dd7eba819569e26a28e749ea9182a8b3b5c5aae268a9d8701cd738610ff4301ad0ea806731859855d51fc0f75171c8ce0c4ab
languageName: node
linkType: hard

"rollup-plugin-sass@npm:^1.12.19":
version: 1.12.20
resolution: "rollup-plugin-sass@npm:1.12.20"
Expand Down Expand Up @@ -13286,6 +13311,13 @@ __metadata:
languageName: node
linkType: hard

"sourcemap-codec@npm:^1.4.8":
version: 1.4.8
resolution: "sourcemap-codec@npm:1.4.8"
checksum: b57981c05611afef31605732b598ccf65124a9fcb03b833532659ac4d29ac0f7bfacbc0d6c5a28a03e84c7510e7e556d758d0bb57786e214660016fb94279316
languageName: node
linkType: hard

"split-string@npm:^3.0.1, split-string@npm:^3.0.2":
version: 3.1.0
resolution: "split-string@npm:3.1.0"
Expand Down Expand Up @@ -13533,6 +13565,15 @@ __metadata:
languageName: node
linkType: hard

"strip-literal@npm:^1.0.1":
version: 1.3.0
resolution: "strip-literal@npm:1.3.0"
dependencies:
acorn: ^8.10.0
checksum: f5fa7e289df8ebe82e90091fd393974faf8871be087ca50114327506519323cf15f2f8fee6ebe68b5e58bfc795269cae8bdc7cb5a83e27b02b3fe953f37b0a89
languageName: node
linkType: hard

"strip-outer@npm:^2.0.0":
version: 2.0.0
resolution: "strip-outer@npm:2.0.0"
Expand Down Expand Up @@ -14439,6 +14480,20 @@ __metadata:
languageName: node
linkType: hard

"vite-plugin-components@npm:^0.13.3":
version: 0.13.3
resolution: "vite-plugin-components@npm:0.13.3"
dependencies:
debug: ^4.3.2
fast-glob: ^3.2.7
magic-string: ^0.25.7
minimatch: ^3.0.4
peerDependencies:
vite: ^2.0.0
checksum: 86c70f26e5e25c2e4611dc74a43a7b72ab437c59a5fa75924b1ac2a3fd876c4d8398385895680de55c1bffcb7869a490c97320836dedd7801b67656bae1f7cfd
languageName: node
linkType: hard

"vite-plugin-static-copy@npm:^0.14.0":
version: 0.14.0
resolution: "vite-plugin-static-copy@npm:0.14.0"
Expand Down

0 comments on commit 0cd21f4

Please sign in to comment.