Skip to content

Commit a19d933

Browse files
committed
✨ Add integration to improve setup and package manager support
1 parent 291603e commit a19d933

File tree

9 files changed

+2284
-1306
lines changed

9 files changed

+2284
-1306
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"svelte.plugin.svelte.compilerWarnings": {},
33
"eslint.validate": [
4+
"javascript",
5+
"javascriptreact",
6+
"typescript",
7+
"typescriptreact",
8+
"astro",
49
"svelte"
510
],
611
"search.exclude": {

eslint.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import eslintPluginAstro from 'eslint-plugin-astro'
88
import eslintPluginReact from 'eslint-plugin-react'
99
import eslintPluginSimpleImportSort from 'eslint-plugin-simple-import-sort'
1010
import eslintPluginSvelte from 'eslint-plugin-svelte'
11+
import globals from 'globals'
1112
import eslintPluginTypeScript from 'typescript-eslint'
1213

1314
export default [
@@ -17,6 +18,12 @@ export default [
1718
...eslintPluginAstro.configs.recommended,
1819
...eslintPluginTypeScript.configs.recommended,
1920
{
21+
languageOptions: {
22+
globals: {
23+
...globals.browser,
24+
...globals.node
25+
}
26+
},
2027
plugins: {
2128
'simple-import-sort': eslintPluginSimpleImportSort
2229
},

package-lock.json

Lines changed: 2211 additions & 1274 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"dev": "astro dev",
99
"build": "astro check && astro build",
1010
"build:package": "node scripts/build.js",
11-
"build:local": "node scripts/build.js --local",
1211
"compile": "node scripts/sass.js",
1312
"test": "vitest run && npm run test:sass",
1413
"test:dev": "vitest",
@@ -51,8 +50,9 @@
5150
"./astro": "./astro.js",
5251
"./svelte": "./svelte.js",
5352
"./react": "./react.js",
54-
"./styles": "./scss/index.scss",
5553
"./icons": "./icons.js",
54+
"./integration": "./integration.js",
55+
"./styles": "./scss/index.scss",
5656
"./config": "./scss/config.scss"
5757
},
5858
"files": [
@@ -70,6 +70,8 @@
7070
"react.js",
7171
"index.js",
7272
"index.d.ts",
73+
"integration.js",
74+
"integration.d.ts",
7375
"README.md",
7476
"LICENSE"
7577
],

scripts/build.js

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { buildIconImports,buildImports, buildUtilImports } from './buildImports.js'
1+
import { buildIconImports, buildImports, buildUtilImports } from './buildImports.js'
22
import buildTypes from './buildTypes.js'
33

44
import fs from 'fs'
@@ -13,19 +13,10 @@ const folders = {
1313
const files = {
1414
'README.md': 'dist/README.md',
1515
'LICENSE': 'dist/LICENSE',
16-
'package.json': 'dist/package.json'
16+
'package.json': 'dist/package.json',
17+
'src/integration.js': 'dist/integration.js'
1718
}
1819

19-
const sassConfigEntry = 'dist/scss/config.scss'
20-
const sassConfigs = [
21-
'dist/scss/config/color-palette.scss',
22-
'dist/scss/config/css-values.scss',
23-
'dist/scss/config/layout.scss',
24-
'dist/scss/config/mixins.scss',
25-
'dist/scss/config/typography.scss',
26-
'dist/scss/config/variables.scss'
27-
]
28-
2920
console.log('🚀 Preparing package build')
3021

3122
if (!fs.existsSync('dist')) {
@@ -37,24 +28,6 @@ Object.keys(folders).forEach(key => {
3728
if (error) {
3829
console.error('🚨 error copying directory', error)
3930
}
40-
41-
if (key.includes('scss') && !process.argv[2]) {
42-
const configFile = fs.readFileSync(sassConfigEntry, 'utf-8')
43-
44-
fs.writeFileSync(
45-
sassConfigEntry,
46-
configFile.replace('webcore.config', '../../../webcore.config')
47-
)
48-
49-
sassConfigs.forEach(config => {
50-
const file = fs.readFileSync(config, 'utf-8')
51-
52-
fs.writeFileSync(
53-
config,
54-
file.replace('webcore.config', '../../../../webcore.config')
55-
)
56-
})
57-
}
5831
})
5932
})
6033

@@ -89,5 +62,6 @@ fs.writeFileSync('dist/svelte.d.ts', buildTypes('svelte'))
8962
fs.writeFileSync('dist/react.d.ts', buildTypes('react'))
9063
fs.writeFileSync('dist/icons.d.ts', buildTypes('icons'))
9164
fs.writeFileSync('dist/index.d.ts', buildTypes('utils'))
65+
fs.writeFileSync('dist/integration.d.ts', buildTypes('integration'))
9266

9367
console.log('✅ Package built')

scripts/buildTypes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getAdditionalTypeExports, getAdditionalTypeImports } from './additionalTypes.js'
2+
import { integrationTypes } from './integrationTypes.js'
23
import { utilityTypes } from './utilityTypes.js'
34

45
import fs from 'fs'
@@ -114,6 +115,10 @@ const buildTypes = type => {
114115
if (type === 'utils') {
115116
return utilityTypes
116117
}
118+
119+
if (type === 'integration') {
120+
return integrationTypes
121+
}
117122
}
118123

119124
export default buildTypes

scripts/integrationTypes.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const integrationTypes = `
2+
import type { AstroIntegration } from 'astro'
3+
import { Plugin } from 'vite'
4+
5+
declare module 'webcoreui/integration' {
6+
export const webcore: () => AstroIntegration
7+
export const webcoreVite: () => Plugin
8+
}
9+
`

src/components/Alert/alert.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { JSX } from 'react'
12
import type { Snippet } from 'svelte'
23

34
export type AlertProps = {

src/integration.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import path from 'path'
2+
3+
const config = {
4+
ssr: {
5+
noExternal: ['webcoreui']
6+
},
7+
css: {
8+
preprocessorOptions: {
9+
scss: {
10+
loadPaths: [
11+
path.resolve(process.cwd())
12+
]
13+
}
14+
}
15+
}
16+
}
17+
18+
export const webcore = () => {
19+
return {
20+
name: 'webcoreui',
21+
hooks: {
22+
'astro:config:setup': ({ updateConfig }) => {
23+
updateConfig({
24+
vite: config
25+
})
26+
}
27+
}
28+
}
29+
}
30+
31+
export const webcoreVite = () => {
32+
return {
33+
name: 'webcoreui',
34+
config() {
35+
return config
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)