Skip to content

Commit

Permalink
feat: migration to wyw-in-js
Browse files Browse the repository at this point in the history
  • Loading branch information
Anber committed Dec 4, 2023
1 parent af4d6b9 commit 5802a8b
Show file tree
Hide file tree
Showing 37 changed files with 1,571 additions and 1,316 deletions.
2 changes: 1 addition & 1 deletion .syncpackrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = {
'workspaces',
'binary',

'linaria',
'wyw-in-js',

'scripts',
'betterScripts',
Expand Down
2 changes: 1 addition & 1 deletion examples/astro-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "module",
"devDependencies": {
"@astrojs/solid-js": "^1.2.3",
"@babel/core": "^7.22.15",
"@babel/core": "^7.23.5",
"@linaria/core": "workspace:^",
"@linaria/shaker": "workspace:^",
"@linaria/vite": "workspace:^",
Expand Down
4 changes: 2 additions & 2 deletions examples/rollup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"linaria-website": "workspace:^"
},
"devDependencies": {
"@babel/core": "^7.22.15",
"@babel/preset-react": "^7.22.15",
"@babel/core": "^7.23.5",
"@babel/preset-react": "^7.23.3",
"@linaria/rollup": "workspace:^",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-commonjs": "^25.0.4",
Expand Down
2 changes: 1 addition & 1 deletion examples/vpssr-linaria-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"license": "ISC",
"dependencies": {
"@linaria/core": "workspace:^",
"@linaria/vite": "workspace:^",
"@wyw-in-js/vite": "^0.1.1",
"babel-preset-solid": "^1.6.2",
"compression": "^1.7.4",
"express": "^4.18.2",
Expand Down
54 changes: 27 additions & 27 deletions examples/vpssr-linaria-solid/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import vite_ssr from "vite-plugin-ssr/plugin";
import vite_linaria from "@linaria/vite";
import vite_solid from "vite-plugin-solid";
import vite_ssr from 'vite-plugin-ssr/plugin';
import vite_wyw from '@wyw-in-js/vite';
import vite_solid from 'vite-plugin-solid';

export default (/** @type import('vite').ConfigEnv */ { mode }) => {
const dev = mode === "development";
/** @type import('vite').UserConfig */
const config = {
plugins: [
vite_linaria({
babelOptions: {
presets: ["solid"],
},
}),
vite_solid({
dev: dev,
hot: dev,
ssr: true,
}),
vite_ssr({
includeAssetsImportedByServer: true,
prerender: {
partial: true,
noExtraDir: true,
},
}),
],
};
return config;
const dev = mode === 'development';
/** @type import('vite').UserConfig */
const config = {
plugins: [
vite_wyw({
babelOptions: {
presets: ['solid'],
},
}),
vite_solid({
dev: dev,
hot: dev,
ssr: true,
}),
vite_ssr({
includeAssetsImportedByServer: true,
prerender: {
partial: true,
noExtraDir: true,
},
}),
],
};
return config;
};
2 changes: 1 addition & 1 deletion examples/webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"linaria-website": "workspace:^"
},
"devDependencies": {
"@babel/core": "^7.22.15",
"@babel/core": "^7.23.5",
"@linaria/webpack5-loader": "workspace:^",
"babel-loader": "^9.1.0",
"cross-env": "^7.0.3",
Expand Down
21 changes: 21 additions & 0 deletions link-wyw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Find package.json files in the current folder (excluding node_modules)
package_json_files=$(find . -name "package.json" ! -path "*/node_modules/*")

# Loop through each package.json file found
for package_json_file in $package_json_files; do
# Get the directory path of the package.json file
package_dir=$(dirname "$package_json_file")

# Get all @linaria/* dependencies
linaria_dependencies=$(cat "$package_json_file" | jq -r '(.dependencies + .devDependencies) | with_entries(select(.key | startswith("@wyw-in-js"))) | keys[]' 2>/dev/null)

# Link @linaria dependencies
if [[ $linaria_dependencies != "null" ]]; then
for dep in $linaria_dependencies; do
echo "Running pnpm link --global $dep in $package_dir"
(cd "$package_dir" && pnpm link --global $dep)
done
fi
done
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@
"git-raw-commits": "^2.0.3"
},
"devDependencies": {
"@babel/cli": "^7.22.15",
"@babel/core": "^7.22.15",
"@babel/eslint-parser": "^7.22.15",
"@babel/plugin-proposal-explicit-resource-management": "^7.22.6",
"@babel/plugin-syntax-jsx": "^7.22.5",
"@babel/preset-env": "^7.22.15",
"@babel/preset-react": "^7.22.15",
"@babel/preset-typescript": "^7.22.15",
"@babel/cli": "^7.23.4",
"@babel/core": "^7.23.5",
"@babel/eslint-parser": "^7.23.3",
"@babel/plugin-proposal-explicit-resource-management": "^7.23.3",
"@babel/plugin-syntax-jsx": "^7.23.3",
"@babel/preset-env": "^7.23.5",
"@babel/preset-react": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@changesets/cli": "^2.22.0",
"@commitlint/config-conventional": "^8.3.4",
"@definitelytyped/dtslint": "^0.0.176",
"@definitelytyped/dtslint": "^0.0.197",
"@types/jest": "^28.1.0",
"@types/node": "^17.0.39",
"@typescript-eslint/eslint-plugin": "^6.6.0",
Expand Down
9 changes: 4 additions & 5 deletions packages/atomic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"processors/",
"types/"
],
"linaria": {
"wyw-in-js": {
"tags": {
"css": "./dist/processors/css.js",
"styled": "./dist/processors/styled.js"
Expand All @@ -50,17 +50,16 @@
},
"dependencies": {
"@linaria/core": "workspace:^",
"@linaria/logger": "workspace:^",
"@linaria/react": "workspace:^",
"@linaria/tags": "workspace:^",
"@linaria/utils": "workspace:^",
"@wyw-in-js/processor-utils": "^0.1.1",
"@wyw-in-js/shared": "^0.1.1",
"known-css-properties": "^0.24.0",
"postcss": "^8.4.31",
"stylis": "^4.3.0",
"ts-invariant": "^0.10.3"
},
"devDependencies": {
"@babel/types": "^7.22.15",
"@babel/types": "^7.23.5",
"@types/node": "^17.0.39",
"@types/stylis": "^4.2.1"
},
Expand Down
11 changes: 5 additions & 6 deletions packages/atomic/src/processors/css.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { SourceLocation } from '@babel/types';
import type { Rules, ValueCache } from '@wyw-in-js/processor-utils';
import { logger } from '@wyw-in-js/shared';

import CssProcessor from '@linaria/core/processors/css';
import { debug } from '@linaria/logger';
import type { Rules, ValueCache } from '@linaria/tags';

import atomize from './helpers/atomize';

const debug = logger.extend('AtomicCssProcessor');

export default class AtomicCssProcessor extends CssProcessor {
#classes: string | undefined;

Expand Down Expand Up @@ -39,10 +41,7 @@ export default class AtomicCssProcessor extends CssProcessor {
atom: true,
};

debug(
'evaluator:template-processor:extracted-atomic-rule',
`\n${rule.cssText}`
);
debug('extracted-atomic-rule:\n%s', rule.cssText);
});

this.#classes = atomicRules
Expand Down
3 changes: 1 addition & 2 deletions packages/atomic/src/processors/helpers/atomize.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { slugify } from '@wyw-in-js/shared';
import { all as knownProperties } from 'known-css-properties';
import type { Document, AtRule, Container, Rule } from 'postcss';
import postcss from 'postcss';
import { compile, serialize, stringify } from 'stylis';

import { slugify } from '@linaria/utils';

import { getPropertyPriority } from './propertyPriority';

const knownPropertiesMap = knownProperties.reduce(
Expand Down
14 changes: 6 additions & 8 deletions packages/atomic/src/processors/styled.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { SourceLocation } from '@babel/types';
import type { Rules, ValueCache } from '@wyw-in-js/processor-utils';
import { logger, hasEvalMeta } from '@wyw-in-js/shared';

import { debug } from '@linaria/logger';
import type { IProps } from '@linaria/react/processors/styled';
import StyledProcessor from '@linaria/react/processors/styled';
import type { Rules, ValueCache } from '@linaria/tags';
import { hasMeta } from '@linaria/utils';

import atomize from './helpers/atomize';

const debug = logger.extend('AtomicStyledProcessor');

export default class AtomicStyledProcessor extends StyledProcessor {
#classes: string | undefined;

Expand All @@ -33,7 +34,7 @@ export default class AtomicStyledProcessor extends StyledProcessor {
? null
: valueCache.get(this.component.node.name);

const atomicRules = atomize(cssText, hasMeta(wrappedValue));
const atomicRules = atomize(cssText, hasEvalMeta(wrappedValue));
atomicRules.forEach((rule) => {
// eslint-disable-next-line no-param-reassign
rules[rule.cssText] = {
Expand All @@ -44,10 +45,7 @@ export default class AtomicStyledProcessor extends StyledProcessor {
atom: true,
};

debug(
'evaluator:template-processor:extracted-atomic-rule',
`\n${rule.cssText}`
);
debug('extracted-atomic-rule:\n%s', rule.cssText);
});

this.#classes = atomicRules
Expand Down
18 changes: 9 additions & 9 deletions packages/babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
"watch": "pnpm build:lib --watch & pnpm build:declarations --watch"
},
"dependencies": {
"@babel/core": "^7.22.15",
"@babel/generator": "^7.22.15",
"@babel/core": "^7.23.5",
"@babel/generator": "^7.23.5",
"@babel/helper-module-imports": "^7.22.15",
"@babel/template": "^7.22.15",
"@babel/traverse": "^7.23.2",
"@babel/types": "^7.22.15",
"@babel/traverse": "^7.23.5",
"@babel/types": "^7.23.5",
"@linaria/core": "workspace:^",
"@linaria/logger": "workspace:^",
"@linaria/shaker": "workspace:^",
Expand All @@ -51,11 +51,11 @@
"ts-invariant": "^0.10.3"
},
"devDependencies": {
"@types/babel__core": "^7.20.1",
"@types/babel__generator": "^7.6.4",
"@types/babel__helper-module-imports": "^7.18.0",
"@types/babel__template": "^7.4.1",
"@types/babel__traverse": "^7.20.1",
"@types/babel__core": "^7.20.5",
"@types/babel__generator": "^7.6.7",
"@types/babel__helper-module-imports": "^7.18.3",
"@types/babel__template": "^7.4.4",
"@types/babel__traverse": "^7.20.4",
"@types/jest": "^28.1.0",
"@types/node": "^17.0.39",
"@types/stylis": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"watch": "pnpm build --watch"
},
"dependencies": {
"@babel/core": "^7.22.15",
"@babel/core": "^7.23.5",
"@linaria/babel-preset": "workspace:^",
"@linaria/utils": "workspace:^",
"glob": "^7.1.3",
Expand Down
17 changes: 8 additions & 9 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"processors/",
"types/"
],
"linaria": {
"wyw-in-js": {
"tags": {
"css": "./dist/processors/css.js"
}
Expand All @@ -58,16 +58,15 @@
"watch": "pnpm build:dist --watch & pnpm build:declarations --watch"
},
"dependencies": {
"@linaria/logger": "workspace:^",
"@linaria/tags": "workspace:^",
"@linaria/utils": "workspace:^"
"@wyw-in-js/processor-utils": "^0.1.1"
},
"devDependencies": {
"@babel/traverse": "^7.23.2",
"@babel/types": "^7.22.15",
"@types/babel__core": "^7.20.1",
"@types/babel__traverse": "^7.20.1",
"@types/node": "^17.0.39"
"@babel/traverse": "^7.23.5",
"@babel/types": "^7.23.5",
"@types/babel__core": "^7.20.5",
"@types/babel__traverse": "^7.20.4",
"@types/node": "^17.0.39",
"@wyw-in-js/shared": "^0.1.1"
},
"engines": {
"node": ">=16.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/css.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { StyledMeta } from '@linaria/utils';
import type { WYWEvalMeta } from '@wyw-in-js/shared';

import type { CSSProperties } from './CSSProperties';
import type { LinariaClassName } from './cx';

type CSS = (
strings: TemplateStringsArray,
...exprs: Array<string | number | CSSProperties | StyledMeta>
...exprs: Array<string | number | CSSProperties | WYWEvalMeta>
) => LinariaClassName;

let idx = 0;
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/processors/css.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { SourceLocation, StringLiteral } from '@babel/types';

import type { Rules, ValueCache } from '@linaria/tags';
import { TaggedTemplateProcessor } from '@linaria/tags';
import type { Rules, ValueCache } from '@wyw-in-js/processor-utils';
import { TaggedTemplateProcessor } from '@wyw-in-js/processor-utils';

export default class CssProcessor extends TaggedTemplateProcessor {
public override get asSelector(): string {
Expand Down
2 changes: 1 addition & 1 deletion packages/esbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"watch": "pnpm build:dist --watch & pnpm build:declarations --watch"
},
"dependencies": {
"@babel/core": "^7.22.15",
"@babel/core": "^7.23.5",
"@linaria/babel-preset": "workspace:^",
"@linaria/utils": "workspace:^"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/griffel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"processors/",
"types/"
],
"linaria": {
"wyw-in-js": {
"tags": {
"makeStyles": "./lib/processors/makeStyles.js"
}
Expand All @@ -44,7 +44,7 @@
"ts-invariant": "^0.10.3"
},
"devDependencies": {
"@babel/types": "^7.22.15"
"@babel/types": "^7.23.5"
},
"engines": {
"node": ">=16.0.0"
Expand Down
Loading

0 comments on commit 5802a8b

Please sign in to comment.