Skip to content

Commit

Permalink
Fix import statements and remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed Feb 22, 2024
1 parent 94f13fd commit 39d7809
Show file tree
Hide file tree
Showing 29 changed files with 88 additions and 80 deletions.
5 changes: 3 additions & 2 deletions examples/nuxt.js-with-runtime-rendering/package.json
Expand Up @@ -12,7 +12,8 @@
"@master/css.vue": "workspace:^"
},
"devDependencies": {
"@types/node": "^20",
"nuxt": "^3.5.2"
"nuxt": "^3.10.2",
"vue": "^3.4.19",
"vue-router": "^4.2.5"
}
}
7 changes: 2 additions & 5 deletions examples/nuxt.js-with-static-extraction/nuxt.config.ts
@@ -1,12 +1,9 @@
import { CSSExtractorPlugin } from '@master/css-extractor.vite'
import CSSExtractorPlugin from '@master/css-extractor.vite'

export default defineNuxtConfig({
vite: {
plugins: [
CSSExtractorPlugin()
],
define: {
__NUXT_ASYNC_CONTEXT__: false
}
]
}
})
15 changes: 9 additions & 6 deletions examples/nuxt.js-with-static-extraction/package.json
@@ -1,16 +1,19 @@
{
"name": "nuxt.js-with-static-extraction",
"type": "module",
"private": true,
"scripts": {
"build": "nuxt prepare && nuxt build",
"dev": "nuxt prepare && nuxt dev",
"generate": "nuxt prepare && nuxt generate",
"preview": "nuxt prepare && nuxt preview"
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"devDependencies": {
"@master/css-runtime": "workspace:^",
"@master/css-extractor.vite": "workspace:^",
"@types/node": "^20",
"nuxt": "^3.9.3"
"nuxt": "^3.10.2",
"vue": "^3.4.19",
"vue-router": "^4.2.5"
}
}
4 changes: 2 additions & 2 deletions examples/nuxt.js/package.json
Expand Up @@ -14,8 +14,8 @@
},
"devDependencies": {
"@types/node": "^20",
"nuxt": "^3.9.3",
"vue": "^3.4.15",
"nuxt": "^3.10.2",
"vue": "^3.4.19",
"vue-router": "^4.2.5"
}
}
9 changes: 8 additions & 1 deletion packages/css/declarations.d.ts
@@ -1,2 +1,9 @@
import './src'
import '@types/jest'
import '@types/jest'

import { default as _MasterCSS } from './src/core'

declare global {
var MasterCSS: typeof _MasterCSS
var masterCSSs: _MasterCSS[]
}
6 changes: 3 additions & 3 deletions packages/css/package.json
Expand Up @@ -2,7 +2,7 @@
"name": "@master/css",
"type": "module",
"scripts": {
"build": "techor build",
"build": "techor build \"src/**/*.ts\"",
"dev": "techor dev",
"test": "jest",
"type-check": "tsc --noEmit",
Expand Down Expand Up @@ -62,10 +62,10 @@
"access": "public"
},
"dependencies": {
"@master/normal.css": "workspace:^"
"@master/normal.css": "workspace:^",
"@techor/extend": "^3.0.10"
},
"devDependencies": {
"@techor/extend": "^3.0.10",
"css-shared": "workspace:^",
"csstype": "^3.1.2"
}
Expand Down
6 changes: 2 additions & 4 deletions packages/css/src/core.ts
Expand Up @@ -6,7 +6,6 @@ import { Layer } from './layer'
import { hexToRgb } from './utils/hex-to-rgb'
import { flattenObject } from './utils/flatten-object'
import { extendConfig } from './utils/extend-config'
import './types/global'
import { PropertiesHyphen } from 'csstype'

type VariableValue =
Expand All @@ -21,7 +20,7 @@ export type Variable = Omit<VariableValue, 'value' | 'space'> & {
themes?: { [theme: string]: VariableValue }
}

export interface MasterCSS {
export default interface MasterCSS {
readonly style: HTMLStyleElement
styles: Record<string, string[]>
stylesBy: Record<string, string[]>
Expand All @@ -33,7 +32,7 @@ export interface MasterCSS {
animations: Record<string, AnimationDefinitions & { usage?: number, native?: NativeRule }>
}

export class MasterCSS {
export default class MasterCSS {
static config: Config = defaultConfig
readonly rules: Rule[] = []
readonly ruleBy: Record<string, Rule> = {}
Expand Down Expand Up @@ -1205,4 +1204,3 @@ export const masterCSSs: MasterCSS[] = [];
globalThis.MasterCSS = MasterCSS
globalThis.masterCSSs = masterCSSs
})()

2 changes: 1 addition & 1 deletion packages/css/src/functions/reorder-for-readable-classes.ts
@@ -1,6 +1,6 @@
import { Layer } from '../layer'
import type { Config } from '../config'
import { MasterCSS } from '../core'
import MasterCSS from '../core'

/**
* Sorts classes in a consistent order
Expand Down
12 changes: 3 additions & 9 deletions packages/css/src/index.ts
@@ -1,14 +1,8 @@
// core
export { MasterCSS, MasterCSS as default } from './core'
export * from './config'
export { Rule } from './rule'
export type { NativeRule, MediaFeatureComponent, MediaQuery } from './rule'

// constants
export { Layer } from './layer'

// functions
export { default as extend } from '@techor/extend'
export { default as reorderForReadableClasses } from './functions/reorder-for-readable-classes'
export { default as MasterCSS, default } from './core'

// config
export * from './config'
export type { NativeRule, MediaFeatureComponent, MediaQuery } from './rule'
4 changes: 2 additions & 2 deletions packages/css/src/rule.ts
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
import type { MasterCSS, Variable } from './core'
import MasterCSS, { type Variable } from './core'
import { START_SYMBOLS } from './constants/start-symbol'
import cssEscape from 'css-shared/utils/css-escape'
import { Layer } from './layer'
Expand Down Expand Up @@ -455,7 +455,7 @@ export class Rule {

let cssText = getCssText(className)
+ (classNames
? classNames.reduce((str, className) => str + ',' + getCssText(className), '')
? classNames.reduce((str: string, className: string) => str + ',' + getCssText(className), '')
: '')
+ '{'
+ propertiesText.join(';')
Expand Down
7 changes: 0 additions & 7 deletions packages/css/src/types/global.ts

This file was deleted.

6 changes: 2 additions & 4 deletions packages/css/tsconfig.json
Expand Up @@ -5,10 +5,8 @@
"outDir": "dist"
},
"include": [
"src/**/*",
"src/**/*.ts",
"declarations.d.ts",
"./setup-jest.ts"
],
"exclude": [
"**/*.d.ts"
]
}
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/utils/get-mastercss.ts
@@ -1,4 +1,4 @@
import MasterCSS, { Config, config } from '@master/css'
import { MasterCSS, Config, config } from '@master/css'
import exploreConfig from 'explore-config'

let currentCSS: MasterCSS
Expand Down
2 changes: 1 addition & 1 deletion packages/extractor.vite/README.md
Expand Up @@ -53,7 +53,7 @@
</div>

```js
import { CSSExtractorPlugin } from '@master/css-extractor.vite'
import CSSExtractorPlugin from '@master/css-extractor.vite'

/** @type {import('vite').UserConfig} */
const config = {
Expand Down
11 changes: 9 additions & 2 deletions packages/extractor.vite/package.json
Expand Up @@ -2,7 +2,7 @@
"name": "@master/css-extractor.vite",
"type": "module",
"scripts": {
"build": "techor build \"src/**/*.ts\" --formats esm",
"build": "techor build \"src/**/*.ts\"",
"dev": "techor dev",
"type-check": "tsc --noEmit",
"lint": "eslint src",
Expand Down Expand Up @@ -33,11 +33,18 @@
"vite-plugin"
],
"sideEffects": false,
"main": "./dist/index.mjs",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"jsnext:main": "./dist/index.mjs",
"esnext": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
}
},
"files": [
"dist"
],
Expand Down
3 changes: 1 addition & 2 deletions packages/extractor.vite/src/index.ts
@@ -1,2 +1 @@

export { default as CSSExtractorPlugin } from './plugins/core'
export { default } from './plugins/core'
7 changes: 4 additions & 3 deletions packages/extractor.vite/src/plugins/core.ts
@@ -1,14 +1,15 @@
import CSSExtractor from '@master/css-extractor'
import { CSSExtractor } from '@master/css-extractor'
import type { Options } from '@master/css-extractor'
import type { Plugin } from 'vite'
import type { Pattern } from 'fast-glob'
import PreInsertionPlugin from './pre-insertion'
import VirtualCSSModulePlugins from './virtual-css-module'

export default function CSSExtractorPlugin(
customOptions?: Options | Pattern | Pattern[]
customOptions?: Options | Pattern,
cwd = process.cwd()
): Plugin[] {
const extractor = new CSSExtractor(customOptions)
const extractor = new CSSExtractor(customOptions, cwd)
extractor.on('init', (options: Options) => {
options.include = []
})
Expand Down
2 changes: 1 addition & 1 deletion packages/extractor.vite/src/plugins/pre-insertion.ts
@@ -1,4 +1,4 @@
import CSSExtractor from '@master/css-extractor'
import { CSSExtractor } from '@master/css-extractor'
import type { Plugin, ViteDevServer } from 'vite'
import { existsSync, readFileSync } from 'fs'
import debounce from 'lodash.debounce'
Expand Down
2 changes: 1 addition & 1 deletion packages/extractor.vite/src/plugins/virtual-css-module.ts
@@ -1,4 +1,4 @@
import CSSExtractor from '@master/css-extractor'
import { CSSExtractor } from '@master/css-extractor'
import type { Plugin } from 'vite'

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/extractor.webpack/README.md
Expand Up @@ -53,7 +53,7 @@
</div>

```js
const { CSSExtractorPlugin } = require('@master/css-extractor.webpack')
const CSSExtractorPlugin = require('@master/css-extractor.webpack')

module.exports = {
plugins: [
Expand Down
6 changes: 4 additions & 2 deletions packages/extractor.webpack/src/index.ts
Expand Up @@ -5,7 +5,7 @@ import log from '@techor/log'

const NAME = 'MasterCSSExtractorPlugin'

export class CSSExtractorPlugin extends CSSExtractor {
export default class CSSExtractorPlugin extends CSSExtractor {

initialized = false
moduleContentByPath: any = {}
Expand Down Expand Up @@ -59,4 +59,6 @@ export class CSSExtractorPlugin extends CSSExtractor {
})
})
}
}
}

exports.__esModule = true
2 changes: 1 addition & 1 deletion packages/extractor/src/core.ts
@@ -1,5 +1,5 @@
import { default as defaultOptions, Options } from './options'
import MasterCSS from '@master/css'
import { MasterCSS } from '@master/css'
import type { Config } from '@master/css'
import extractLatentClasses from './functions/extract-latent-classes'
import fs from 'fs'
Expand Down
6 changes: 4 additions & 2 deletions packages/extractor/src/index.ts
@@ -1,5 +1,7 @@
export * from './options'
export * from './constants'
export * from './core'

export { default as options } from './options'
export { default, default as CSSExtractor } from './core'
export { default as extractLatentClasses } from './functions/extract-latent-classes'
export { default as extractLatentClasses } from './functions/extract-latent-classes'
export { default as CSSExtractor, default } from './core'
2 changes: 1 addition & 1 deletion packages/language-service/src/providers/hover.ts
@@ -1,5 +1,5 @@
import type { Hover, Range } from 'vscode-languageserver-types'
import MasterCSS from '@master/css'
import { MasterCSS } from '@master/css'
import { getCssEntryMarkdownDescription } from '../utils/get-css-entry-markdown-description'
import { masterCssKeyValues } from '../constant'
// @ts-expect-error
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/render-css.ts
@@ -1,5 +1,5 @@
import parseHTML from './parse-html'
import MasterCSS, { Config } from '@master/css'
import { MasterCSS, Config } from '@master/css'

/**
* Renders the Master CSS string from HTML
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/render.ts
@@ -1,4 +1,4 @@
import MasterCSS, { Config } from '@master/css'
import { MasterCSS, Config } from '@master/css'
import parseHTML from './parse-html'
import { Element, Text, ChildNode } from 'domhandler'
import serialize from 'dom-serializer'
Expand Down

0 comments on commit 39d7809

Please sign in to comment.