Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tags): extract tags logic to the separate package (fixes #1006) #1007

Merged
merged 1 commit into from Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions .changeset/itchy-ears-judge.md
@@ -0,0 +1,25 @@
---
'@linaria/atomic': patch
'@linaria/babel-preset': patch
'@linaria/cli': patch
'@linaria/core': patch
'@linaria/esbuild': patch
'@linaria/extractor': patch
'@linaria/babel-plugin-interop': patch
'linaria': patch
'@linaria/logger': patch
'@linaria/react': patch
'@linaria/rollup': patch
'@linaria/server': patch
'@linaria/shaker': patch
'@linaria/stylelint': patch
'@linaria/tags': patch
'@linaria/testkit': patch
'@linaria/utils': patch
'@linaria/webpack-loader': patch
'@linaria/webpack4-loader': patch
'@linaria/webpack5-loader': patch
'linaria-website': patch
---

New package @linaria/tags that contains all abstract logic for tags processors.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -37,13 +37,13 @@ Zero-runtime CSS in JS library.
## Installation

```sh
npm install @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
npm install @linaria/core @linaria/react @linaria/babel-preset
```

or

```sh
yarn add @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
yarn add @linaria/core @linaria/react @linaria/babel-preset
```

## Setup
Expand Down
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -6,9 +6,9 @@
"git-raw-commits": "^2.0.3"
},
"devDependencies": {
"@babel/cli": "^7.17.10",
"@babel/core": "^7.18.2",
"@babel/eslint-parser": "^7.18.2",
"@babel/cli": "^7.18.9",
"@babel/core": "^7.18.9",
"@babel/eslint-parser": "^7.18.9",
"@babel/plugin-proposal-class-properties": ">=7",
"@babel/plugin-syntax-jsx": ">=7",
"@babel/preset-env": ">=7",
Expand Down Expand Up @@ -41,7 +41,7 @@
"react": "^16.14.0",
"syncpack": "^8.0.0",
"turbo": "^1.2.16",
"typescript": "^4.7.3"
"typescript": "^4.7.4"
},
"engines": {
"node": "^12.16.0 || >=13.7.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/atomic/README.md
Expand Up @@ -25,11 +25,11 @@ Zero-runtime CSS in JS library.
## Installation

```sh
npm install @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
npm install @linaria/core @linaria/react @linaria/babel-preset
```

or

```sh
yarn add @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
yarn add @linaria/core @linaria/react @linaria/babel-preset
```
3 changes: 2 additions & 1 deletion packages/atomic/package.json
Expand Up @@ -7,14 +7,15 @@
"@linaria/core": "workspace:^",
"@linaria/logger": "workspace:^",
"@linaria/react": "workspace:^",
"@linaria/tags": "workspace:^",
"@linaria/utils": "workspace:^",
"known-css-properties": "^0.24.0",
"postcss": "^8.3.11",
"stylis": "^3.5.4",
"ts-invariant": "^0.10.3"
},
"devDependencies": {
"@babel/types": "^7.18.4"
"@babel/types": "^7.18.9"
},
"engines": {
"node": "^12.16.0 || >=13.7.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic/src/processors/css.ts
@@ -1,8 +1,8 @@
import type { SourceLocation } from '@babel/types';

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

import atomize from './helpers/atomize';

Expand Down
4 changes: 2 additions & 2 deletions packages/atomic/src/processors/styled.ts
@@ -1,10 +1,10 @@
import type { SourceLocation } from '@babel/types';

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

import atomize from './helpers/atomize';
Expand Down
4 changes: 2 additions & 2 deletions packages/babel/README.md
Expand Up @@ -25,11 +25,11 @@ Zero-runtime CSS in JS library.
## Installation

```sh
npm install @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
npm install @linaria/core @linaria/react @linaria/babel-preset
```

or

```sh
yarn add @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
yarn add @linaria/core @linaria/react @linaria/babel-preset
```
13 changes: 7 additions & 6 deletions packages/babel/package.json
Expand Up @@ -4,14 +4,15 @@
"version": "3.0.0-beta.21",
"bugs": "https://github.com/callstack/linaria/issues",
"dependencies": {
"@babel/core": "^7.18.2",
"@babel/generator": ">=7",
"@babel/template": ">=7",
"@babel/traverse": ">=7",
"@babel/types": "^7.18.4",
"@babel/core": "^7.18.9",
"@babel/generator": "^7.18.9",
"@babel/template": "^7.18.6",
"@babel/traverse": "^7.18.9",
"@babel/types": "^7.18.9",
"@linaria/core": "workspace:^",
"@linaria/logger": "workspace:^",
"@linaria/shaker": "workspace:^",
"@linaria/tags": "workspace:^",
"@linaria/utils": "workspace:^",
"cosmiconfig": "^5.1.0",
"find-up": "^5.0.0",
Expand All @@ -31,7 +32,7 @@
"jest": "^28.1.0",
"strip-ansi": "^5.2.0",
"ts-jest": "^28.0.4",
"typescript": "^4.7.3"
"typescript": "^4.7.4"
},
"engines": {
"node": "^12.16.0 || >=13.7.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/babel/src/module.ts
Expand Up @@ -18,9 +18,9 @@ import vm from 'vm';

import type { BabelFileResult } from '@babel/core';

import type BaseProcessor from '@linaria/core/types/processors/BaseProcessor';
import type { CustomDebug } from '@linaria/logger';
import { createCustomDebug } from '@linaria/logger';
import type { BaseProcessor } from '@linaria/tags';
import type { StrictOptions } from '@linaria/utils';
import { getFileIdx } from '@linaria/utils';

Expand Down
2 changes: 1 addition & 1 deletion packages/babel/src/transform-stages/2-eval.ts
@@ -1,5 +1,5 @@
import type { ValueCache } from '@linaria/core/types/processors/types';
import { createCustomDebug } from '@linaria/logger';
import type { ValueCache } from '@linaria/tags';
import { getFileIdx } from '@linaria/utils';

import evaluate from '../evaluators';
Expand Down
3 changes: 1 addition & 2 deletions packages/babel/src/transform-stages/4-extract.ts
Expand Up @@ -4,8 +4,7 @@ import type { Mapping } from 'source-map';
import { SourceMapGenerator } from 'source-map';
import stylis from 'stylis';

import type BaseProcessor from '@linaria/core/types/processors/BaseProcessor';
import type { Replacements } from '@linaria/core/types/processors/types';
import type { BaseProcessor, Replacements } from '@linaria/tags';

import type { Rules, Options, PreprocessorFn } from '../types';

Expand Down
6 changes: 3 additions & 3 deletions packages/babel/src/types.ts
Expand Up @@ -3,7 +3,7 @@ import type { NodePath } from '@babel/traverse';
import type { File } from '@babel/types';
import type { RawSourceMap } from 'source-map';

import type BaseProcessor from '@linaria/core/processors/BaseProcessor';
import type { BaseProcessor } from '@linaria/tags';

import type { PluginOptions } from './transform-stages/helpers/loadLinariaOptions';

Expand All @@ -18,9 +18,9 @@ export type {
Serializable,
Value,
ValueCache,
} from '@linaria/core/processors/types';
} from '@linaria/tags';

export { ValueType } from '@linaria/core/processors/types';
export { ValueType } from '@linaria/tags';

export interface ICSSRule {
className: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/babel/src/utils/collectTemplateDependencies.ts
Expand Up @@ -25,8 +25,8 @@ import type {
} from '@babel/types';
import { cloneNode } from '@babel/types';

import hasMeta from '@linaria/core/processors/utils/hasMeta';
import { debug } from '@linaria/logger';
import { hasMeta } from '@linaria/tags';
import {
findIdentifiers,
mutate,
Expand Down
5 changes: 2 additions & 3 deletions packages/babel/src/utils/getTagProcessor.ts
Expand Up @@ -10,9 +10,8 @@ import type {
} from '@babel/types';
import findUp from 'find-up';

import BaseProcessor from '@linaria/core/processors/BaseProcessor';
import type { Params } from '@linaria/core/processors/types';
import type { IFileContext } from '@linaria/core/processors/utils/types';
import { BaseProcessor } from '@linaria/tags';
import type { Params, IFileContext } from '@linaria/tags';
import type { IImport, StrictOptions } from '@linaria/utils';
import {
collectExportsAndImports,
Expand Down
2 changes: 1 addition & 1 deletion packages/babel/src/utils/hasLinariaPreval.ts
@@ -1,4 +1,4 @@
import type { Value } from '@linaria/core/processors/types';
import type { Value } from '@linaria/tags';

export default function hasLinariaPreval(exports: unknown): exports is {
__linariaPreval: Record<string, () => Value> | null | undefined;
Expand Down
3 changes: 1 addition & 2 deletions packages/babel/src/utils/processTemplateExpression.ts
@@ -1,8 +1,7 @@
import type { NodePath } from '@babel/traverse';
import type { TaggedTemplateExpression } from '@babel/types';

import type BaseProcessor from '@linaria/core/processors/BaseProcessor';
import type { IFileContext } from '@linaria/core/processors/utils/types';
import type { BaseProcessor, IFileContext } from '@linaria/tags';
import type { StrictOptions } from '@linaria/utils';

import getTagProcessor from './getTagProcessor';
Expand Down
2 changes: 1 addition & 1 deletion packages/babel/src/utils/vlueToLiteral.ts
@@ -1,7 +1,7 @@
import type { NodePath } from '@babel/traverse';
import type { Expression } from '@babel/types';

import isSerializable from '@linaria/core/processors/utils/isSerializable';
import { isSerializable } from '@linaria/tags';

import getSource from './getSource';

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/README.md
Expand Up @@ -25,11 +25,11 @@ Zero-runtime CSS in JS library.
## Installation

```sh
npm install @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
npm install @linaria/core @linaria/react @linaria/babel-preset
```

or

```sh
yarn add @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
yarn add @linaria/core @linaria/react @linaria/babel-preset
```
2 changes: 1 addition & 1 deletion packages/cli/package.json
Expand Up @@ -7,7 +7,7 @@
},
"bugs": "https://github.com/callstack/linaria/issues",
"dependencies": {
"@babel/core": "^7.18.2",
"@babel/core": "^7.18.9",
"@linaria/babel-preset": "workspace:^",
"@linaria/utils": "workspace:^",
"glob": "^7.1.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/README.md
Expand Up @@ -25,11 +25,11 @@ Zero-runtime CSS in JS library.
## Installation

```sh
npm install @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
npm install @linaria/core @linaria/react @linaria/babel-preset
```

or

```sh
yarn add @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
yarn add @linaria/core @linaria/react @linaria/babel-preset
```
@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { css, cx, LinariaClassName } from '../src';
import { css, cx } from '../src';

// $ExpectType LinariaClassName
const class1 = css``;
Expand Down
1 change: 1 addition & 0 deletions packages/core/__dtslint__/tsconfig.json
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"target": "ES2015",
"esModuleInterop": true,
"noImplicitAny": true,
"noImplicitThis": true,
Expand Down
5 changes: 3 additions & 2 deletions packages/core/package.json
Expand Up @@ -5,11 +5,12 @@
"bugs": "https://github.com/callstack/linaria/issues",
"dependencies": {
"@linaria/logger": "workspace:^",
"@linaria/tags": "workspace:^",
"@linaria/utils": "workspace:^"
},
"devDependencies": {
"@babel/traverse": ">=7",
"@babel/types": "^7.18.4",
"@babel/traverse": "^7.18.9",
"@babel/types": "^7.18.9",
"@types/babel__core": "^7.1.19",
"@types/babel__traverse": "^7.17.1",
"@types/node": "^17.0.39"
Expand Down
5 changes: 0 additions & 5 deletions packages/core/processors/BaseProcessor.js

This file was deleted.

6 changes: 0 additions & 6 deletions packages/core/src/StyledMeta.ts

This file was deleted.

3 changes: 2 additions & 1 deletion packages/core/src/css.ts
@@ -1,5 +1,6 @@
import type { StyledMeta } from '@linaria/tags';

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

type CSS = (
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/index.ts
@@ -1,5 +1,4 @@
export { default as css } from './css';
export { default as cx } from './cx';
export type { CSSProperties } from './CSSProperties';
export type { StyledMeta } from './StyledMeta';
export type { LinariaClassName } from './cx';
5 changes: 2 additions & 3 deletions packages/core/src/processors/css.ts
@@ -1,8 +1,7 @@
import type { Expression, SourceLocation, StringLiteral } from '@babel/types';

import type { ProcessorParams } from './BaseProcessor';
import BaseProcessor from './BaseProcessor';
import type { Rules, ValueCache } from './types';
import type { ProcessorParams, Rules, ValueCache } from '@linaria/tags';
import { BaseProcessor } from '@linaria/tags';

export default class CssProcessor extends BaseProcessor {
constructor(...args: ProcessorParams) {
Expand Down
4 changes: 2 additions & 2 deletions packages/esbuild/README.md
Expand Up @@ -25,11 +25,11 @@ Zero-runtime CSS in JS library.
## Installation

```sh
npm install @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
npm install @linaria/core @linaria/react @linaria/babel-preset
```

or

```sh
yarn add @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
yarn add @linaria/core @linaria/react @linaria/babel-preset
```
2 changes: 1 addition & 1 deletion packages/esbuild/package.json
Expand Up @@ -4,7 +4,7 @@
"version": "3.0.0-beta.21",
"bugs": "https://github.com/callstack/linaria/issues",
"dependencies": {
"@babel/core": "^7.18.2",
"@babel/core": "^7.18.9",
"@linaria/babel-preset": "workspace:^",
"@linaria/utils": "workspace:^",
"esbuild": "^0.12.5"
Expand Down
4 changes: 2 additions & 2 deletions packages/extractor/README.md
Expand Up @@ -25,11 +25,11 @@ Zero-runtime CSS in JS library.
## Installation

```sh
npm install @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
npm install @linaria/core @linaria/react @linaria/babel-preset
```

or

```sh
yarn add @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
yarn add @linaria/core @linaria/react @linaria/babel-preset
```