Skip to content

Commit

Permalink
fix(builddir): check for undefined not false
Browse files Browse the repository at this point in the history
  • Loading branch information
Tahul committed Oct 17, 2023
1 parent 7b38e0e commit eb53933
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 115 deletions.
6 changes: 6 additions & 0 deletions examples/nuxt/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
<NuxtPage />
</App>
</template>

<style lang="ts">
css({
color: ''
})
</style>
10 changes: 3 additions & 7 deletions examples/nuxt/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ export default defineNuxtConfig({
},
],
pinceau: {
theme: {
layers: [
{
path: resolve('../../packages/palette/'),
},
],
},
style: {
excludes: [
resolve('../../packages'),
],
},
theme: {
buildDir: resolve('./.nuxt/pinceau/')
}
},
typescript: {
includeWorkspace: true,
Expand Down
3 changes: 2 additions & 1 deletion examples/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"preview": "nuxi preview"
},
"dependencies": {
"@pinceau/nuxt": "workspace:*"
"@pinceau/nuxt": "workspace:*",
"@pinceau/palette": "workspace:*"
},
"devDependencies": {
"@pinceau/configs": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions integrations/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"dependencies": {
"@nuxt/kit": "^3.7.4",
"@pinceau/integration": "workspace:*",
"@pinceau/palette": "workspace:*",
"@pinceau/vue": "workspace:*"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion integrations/nuxt/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ const module: any = defineNuxtModule<PinceauUserOptions>({
tsConfig.compilerOptions.paths['$pinceau/utils'] = [`${resolve(options.theme.buildDir, 'utils.ts')}`]
tsConfig.compilerOptions.paths['$pinceau/theme'] = [`${resolve(options.theme.buildDir, 'theme.ts')}`]
tsConfig.compilerOptions.paths['$pinceau/vue-plugin'] = [`${resolve(options.theme.buildDir, 'vue-plugin.ts')}`]
tsConfig.compilerOptions.paths.$pinceau = [`${resolve(options.theme.buildDir, 'runtime.ts')}`]
if (options.theme.schema) { tsConfig.compilerOptions.paths['$pinceau/schema'] = [`${resolve(options.theme.buildDir, 'schema.ts')}`] }
if (options.theme.definitions) { tsConfig.compilerOptions.paths['$pinceau/definitions'] = [`${resolve(options.theme.buildDir, 'definitions.ts')}`] }
}
Expand Down
10 changes: 9 additions & 1 deletion integrations/repl/src/components/monaco/cdn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,15 @@ export function createJsDelivrFs(onReadFile?: (uri: string, content: string) =>
if (pkgName.startsWith('@typescript/') || pkgName.startsWith('@types/typescript__')) {
return false
}
if (pkgName.includes('postcss') || pkgName.includes('rspack') || pkgName.includes('unplugin') || pkgName.includes('vite') || pkgName.includes('@pinceau/core')) {
if (
pkgName.includes('postcss')
|| pkgName.includes('rspack')
|| pkgName.includes('unplugin')
|| pkgName.includes('vite')
|| pkgName.includes('csstype')
|| pkgName.includes('rollup')
|| pkgName.includes('ast-types')
) {
return false
}
// don't check @types if original package already having types
Expand Down
10 changes: 6 additions & 4 deletions integrations/repl/src/components/monaco/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export function initMonaco(store: Store) {
}

getOrCreateModel(
Uri.parse(`file:///${filename}`),
file.language,
Uri.parse(filename),
'typescript',
file.code,
)
}
Expand Down Expand Up @@ -135,7 +135,8 @@ export async function reloadLanguageTools(store: Store, lang?: 'vue' | 'svelte'
return Uri.parse(`file:///${filename}`)
})

let _disposeMarkers = () => {}
const _disposeMarkers = () => { }
/*
if (lang === 'vue') {
const { dispose: disposeMarkers } = volar.editor.activateMarkers(
worker,
Expand All @@ -146,6 +147,7 @@ export async function reloadLanguageTools(store: Store, lang?: 'vue' | 'svelte'
)
_disposeMarkers = disposeMarkers
}
*/

/*
const { dispose: disposeAutoInsertion } = volar.editor.activateAutoInsertion(
Expand All @@ -165,7 +167,7 @@ export async function reloadLanguageTools(store: Store, lang?: 'vue' | 'svelte'

disposeWorker = () => {
_disposeMarkers?.()
disposeAutoInsertion?.()
// disposeAutoInsertion?.()
disposeProvides?.()
}
}
Expand Down
2 changes: 1 addition & 1 deletion integrations/repl/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { PinceauProvider } from './pinceau'
export const importMapFile = 'import-map.json'
export const tsconfigFile = 'tsconfig.json'
export const themeFile = 'theme.config.ts'
export const pinceauVersion = '1.0.0-beta.14'
export const pinceauVersion = '1.0.0-beta.16'

const supportedTransformers = {
vue: ReplVueTransformer,
Expand Down
7 changes: 7 additions & 0 deletions integrations/repl/src/store/pinceau.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
declarationFormat,
generateTheme,
javascriptFormat,
pinceauNameTransformer,
pinceauVariableTransformer,
resolveConfigContent,
resolveMediaQueriesKeys,
typescriptFormat,
Expand Down Expand Up @@ -48,6 +50,10 @@ export class PinceauProvider {
utilsTypesFormat,
typescriptFormat,
],
tokensTransforms: [
pinceauNameTransformer,
pinceauVariableTransformer,
],
},
})

Expand All @@ -70,6 +76,7 @@ import type { CSSFunctionArg } from '@pinceau/style'
import type { StyledFunctionArg } from '@pinceau/style'
import type { ThemeTokens } from '@pinceau/style'
declare global {
export type ThemeTokens<T extends PinceauThemePaths & (string & {}) = PinceauThemePaths & (string & {})> = PinceauThemeTokens<T>
export const styled: (<Props extends {} = {}>(declaration: StyledFunctionArg<Props>) => string)
Expand Down
1 change: 1 addition & 0 deletions integrations/repl/src/store/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class ReplReactTransformer implements ReplTransformer<null, {}> {
'globals.d.ts': new File('globals.d.ts', `import * as React from 'react'
import * as ReactDOM from 'react-dom'
import type { ReactStyledComponentFactory } from \'@pinceau/react\'
import { SupportedHTMLElements } from \'@pinceau/style\'
export {}
Expand Down
2 changes: 1 addition & 1 deletion integrations/repl/src/store/svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class ReplSvelteTransformer implements ReplTransformer {
import 'svelte/elements';
import type { SvelteStyledComponentFactory } from \'@pinceau/svelte\'
import { ResponsiveProp } from \'@pinceau/style\'
import { StyledFunctionArg } from \'@pinceau/style\'
import { SupportedHTMLElements } from \'@pinceau/style\'
declare global {
export type ResponsiveProp<T extends string | number | symbol | undefined> = ResponsiveProp<T>
Expand Down
10 changes: 6 additions & 4 deletions integrations/repl/src/store/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,18 @@ export class ReplVueTransformer implements ReplTransformer<typeof defaultCompile
shims = {
'global.d.ts': new File('global.d.ts', `
import type { VueStyledComponentFactory } from \'@pinceau/vue\'
import { ResponsiveProp } from \'@pinceau/style\'
import { StyledFunctionArg } from \'@pinceau/style\'
import { PropType } from \'vue\'
import type { PropType } from \'vue\'
import type { StyledFunctionArg, SupportedHTMLElements, ResponsiveProp } from \'@pinceau/style\'
declare global {
export type ResponsiveProp<T extends string | number | symbol | undefined> = PropType<ResponsiveProp<T>>
export type StyledProp = PropType<StyledFunctionArg>
export const $styled: { [Type in SupportedHTMLElements]: VueStyledComponentFactory<Type> }
declare module \'@vue/runtime-dom\' { interface HTMLAttributes { styled?: StyledFunctionArg } }
}
declare module \'@vue/runtime-dom\' { interface HTMLAttributes { styled?: StyledFunctionArg } }
export {}
`),
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"docs": "nuxi dev docs",
"lint": "eslint --cache .",
"lint:fix": "eslint --cache . --fix",
"palette": "pnpm -r --filter=\"./(packages|integrations)/palette\" run build",
"palette": "pnpm -r --filter=\"./(packages|integrations)/palette\" run build:palette",
"prepare": "pnpm stub",
"release": "bumpp -r package.json packages/*/package.json integrations/*/package.json",
"stub": "pnpm -r --filter=\"./(packages|integrations)/*\" run stub && pnpm -r run build:post",
Expand Down
3 changes: 2 additions & 1 deletion packages/theme/src/utils/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export async function generateTheme(
// Enforce ending slash for buildDir
if (buildDir && !buildDir.endsWith('/')) { buildDir += '/' }

if (buildDir !== false && ctx.options.cwd) { buildDir = join(ctx.options.cwd, 'node_modules/.pinceau/') }
// Enforce buildDir when not set; `false` disables write
if (buildDir === undefined && ctx.options.cwd) { buildDir = join(ctx.options.cwd, 'node_modules/.pinceau/') }

// Transforms used
const usedTransforms = ['size/px', 'color/hex']
Expand Down
Loading

0 comments on commit eb53933

Please sign in to comment.