Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: atlassian-labs/compiled
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: @compiled/react@0.16.2
Choose a base ref
...
head repository: atlassian-labs/compiled
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: @compiled/react@0.16.3
Choose a head ref
  • 13 commits
  • 69 files changed
  • 5 contributors

Commits on Nov 7, 2023

  1. Copy the full SHA
    28559a5 View commit details
  2. Fix xcss eslint rules not compatible with eslint v7 (#1556)

    * Fix xcss eslint rules not compatible with eslint v7
    
    * Add changeset
    dddlr authored Nov 7, 2023
    Copy the full SHA
    c6e2e87 View commit details
  3. Version Packages (#1555)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    atlas-dst-bot and github-actions[bot] authored Nov 7, 2023
    Copy the full SHA
    a11a097 View commit details

Commits on Nov 14, 2023

  1. Copy the full SHA
    fbc17ed View commit details

Commits on Nov 15, 2023

  1. Version Packages (#1559)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    atlas-dst-bot and github-actions[bot] authored Nov 15, 2023
    Copy the full SHA
    cee00f8 View commit details

Commits on Nov 17, 2023

  1. Add ignoreIfImported and excludeReactComponents options to `no-cs…

    …s-prop-without-css-function` ESLint rule (#1560)
    
    * Add ignoreIfImported option to no-css-prop-without-css-function
    
    * Add excludeReactComponents option to no-css-prop-without-css-function
    
    * Add changeset
    dddlr authored Nov 17, 2023
    Copy the full SHA
    2d1a5e7 View commit details

Commits on Nov 20, 2023

  1. Version Packages (#1561)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    atlas-dst-bot and github-actions[bot] authored Nov 20, 2023
    Copy the full SHA
    08e2cfc View commit details

Commits on Nov 21, 2023

  1. Fix xcss prop not being compatible with Emotion (#1563)

    * Fix xcss prop not being compatible with Emotion
    
    * Change changeset to patch
    dddlr authored Nov 21, 2023
    Copy the full SHA
    52ea5ab View commit details

Commits on Nov 23, 2023

  1. Update jsx-pragma documentation (#1562)

    * Update jsx-pragma documentation
    
    * Fix typo
    dddlr authored Nov 23, 2023
    Copy the full SHA
    3aa99f2 View commit details

Commits on Nov 27, 2023

  1. Added Babel Plugin 0.19.0 Patch from JFE (#1565)

    * Manually implemented 0.19.0 plugin patch from JFE -- this patch throws an error when `innerRef` is used in the development/debugging environment instead of `ref`
    
    * Updated snapshots for unit tests
    
    * Added minor changeset with useful description
    zerosicx authored Nov 27, 2023
    Copy the full SHA
    9860df3 View commit details
  2. Version Packages (#1564)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    atlas-dst-bot and github-actions[bot] authored Nov 27, 2023
    Copy the full SHA
    765b599 View commit details

Commits on Dec 3, 2023

  1. Introduce createStrictAPI (#1566)

    * feat: add create api exploration
    
    * fix: type violation when using xcess properties
    
    * feat: add css map types to create api
    
    * chore: add to test case
    
    * chore: another test case
    
    * chore: fix types
    
    * chore: expose cs
    
    * chore: fix
    
    * feat: adds spike code
    
    * feat: add xcss func type
    
    * chore: rename api
    
    * fix: pseudo support for xcss prop
    
    * chore: separate test cases
    
    * chore: fix test
    
    * chore: move api behind a module
    
    * feat: add support for custom module origins
    
    * chore: add assertions to xcss prop usage
    
    * chore: add assertions for css()
    
    * chore: add tests for cssMap()
    
    * feat: add support for absolute/pkg paths
    
    * chore: rename to import sources
    
    * chore: rename to strict
    
    * chore: update jsdoc
    
    * chore: add jsdoc
    
    * chore: stub
    
    * chore: rename
    
    * chore: fix tests
    
    * chore: fix build
    
    * chore: changeset
    
    * chore: use root path
    
    * chore: remove example tags
    
    * chore: update error message to give as much context as possible
    itsdouges authored Dec 3, 2023
    Copy the full SHA
    9857009 View commit details
  2. Version Packages (#1570)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    atlas-dst-bot and github-actions[bot] authored Dec 3, 2023
    Copy the full SHA
    973596c View commit details
Showing with 1,884 additions and 137 deletions.
  1. +5 −1 babel.config.json
  2. +9 −0 fixtures/strict-api-test/package.json
  3. +12 −0 fixtures/strict-api-test/src/index.ts
  4. +14 −0 packages/babel-plugin-strip-runtime/CHANGELOG.md
  5. +3 −3 packages/babel-plugin-strip-runtime/package.json
  6. +189 −2 packages/babel-plugin-strip-runtime/src/__tests__/strip-runtime-source-code.test.ts
  7. +4 −4 packages/babel-plugin-strip-runtime/src/__tests__/strip-runtime-transpiled-code.test.ts
  8. +63 −3 packages/babel-plugin-strip-runtime/src/index.ts
  9. +19 −16 packages/babel-plugin-strip-runtime/src/types.ts
  10. +40 −0 packages/babel-plugin-strip-runtime/src/utils/get-jsx-pragma.ts
  11. +3 −2 packages/babel-plugin-strip-runtime/src/utils/is-create-element.ts
  12. +70 −0 packages/babel-plugin/CHANGELOG.md
  13. +3 −3 packages/babel-plugin/package.json
  14. +88 −0 packages/babel-plugin/src/__tests__/custom-import-source.test.ts
  15. +1 −1 packages/babel-plugin/src/__tests__/errors.test.ts
  16. +3 −0 packages/babel-plugin/src/__tests__/index.test.ts
  17. +3 −0 packages/babel-plugin/src/__tests__/jsx-automatic.test.ts
  18. +3 −0 packages/babel-plugin/src/__tests__/module-imports.test.ts
  19. +56 −14 packages/babel-plugin/src/babel-plugin.ts
  20. +36 −0 packages/babel-plugin/src/keyframes/__tests__/call-expression.test.ts
  21. +18 −0 packages/babel-plugin/src/keyframes/__tests__/tagged-template-expression.test.ts
  22. +14 −3 packages/babel-plugin/src/styled/__tests__/behaviour.test.ts
  23. +12 −0 packages/babel-plugin/src/styled/__tests__/call-expression.test.ts
  24. +12 −0 packages/babel-plugin/src/styled/__tests__/tagged-template-expression.test.ts
  25. +20 −0 packages/babel-plugin/src/types.ts
  26. +11 −0 packages/babel-plugin/src/utils/build-styled-component.ts
  27. +8 −1 packages/babel-plugin/src/utils/css-builders.ts
  28. +191 −0 packages/babel-plugin/src/xcss-prop/__tests__/transformation.test.ts
  29. +7 −0 packages/codemods/CHANGELOG.md
  30. +2 −2 packages/codemods/package.json
  31. +7 −0 packages/css/CHANGELOG.md
  32. +2 −2 packages/css/package.json
  33. +29 −0 packages/eslint-plugin/CHANGELOG.md
  34. +4 −1 packages/eslint-plugin/package.json
  35. +3 −12 packages/eslint-plugin/src/rules/jsx-pragma/README.md
  36. +25 −0 packages/eslint-plugin/src/rules/no-css-prop-without-css-function/README.md
  37. +51 −0 packages/eslint-plugin/src/rules/no-css-prop-without-css-function/__tests__/rule.test.ts
  38. +61 −13 packages/eslint-plugin/src/rules/no-css-prop-without-css-function/index.ts
  39. +2 −1 packages/eslint-plugin/src/rules/no-exported-css/index.ts
  40. +2 −1 packages/eslint-plugin/src/rules/no-exported-keyframes/index.ts
  41. +1 −1 packages/eslint-plugin/src/rules/no-js-xcss/index.ts
  42. +1 −1 packages/eslint-plugin/src/rules/no-suppress-xcss/index.ts
  43. +26 −9 packages/eslint-plugin/src/utils/ast.ts
  44. +12 −4 packages/eslint-plugin/src/utils/jsx.ts
  45. +1 −1 packages/eslint-plugin/tsconfig.json
  46. +8 −0 packages/parcel-optimizer/CHANGELOG.md
  47. +3 −3 packages/parcel-optimizer/package.json
  48. +17 −0 packages/parcel-transformer/CHANGELOG.md
  49. +4 −4 packages/parcel-transformer/package.json
  50. +3 −2 packages/parcel-transformer/src/__tests__/transformer.parceltest.ts
  51. +49 −0 packages/react/CHANGELOG.md
  52. +2 −1 packages/react/package.json
  53. +1 −1 packages/react/src/class-names/index.ts
  54. +13 −0 packages/react/src/create-strict-api/__tests__/__fixtures__/strict-api.ts
  55. +312 −0 packages/react/src/create-strict-api/__tests__/index.test.tsx
  56. +21 −0 packages/react/src/create-strict-api/__tests__/package.test.tsx
  57. +223 −0 packages/react/src/create-strict-api/index.ts
  58. +3 −5 packages/react/src/css-map/index.ts
  59. +1 −1 packages/react/src/css/index.ts
  60. +1 −0 packages/react/src/index.ts
  61. +8 −2 packages/react/src/types.ts
  62. +33 −10 packages/react/src/xcss-prop/index.ts
  63. +8 −0 packages/utils/CHANGELOG.md
  64. +1 −1 packages/utils/package.json
  65. +1 −0 packages/utils/src/index.ts
  66. +2 −0 packages/utils/src/jsx.ts
  67. +18 −0 packages/webpack-loader/CHANGELOG.md
  68. +5 −5 packages/webpack-loader/package.json
  69. +1 −1 packages/webpack-loader/src/__tests__/compiled-loader.test.ts
6 changes: 5 additions & 1 deletion babel.config.json
Original file line number Diff line number Diff line change
@@ -19,7 +19,11 @@
{
"nonce": "\"k0Mp1lEd\"",
"importReact": false,
"optimizeCss": false
"optimizeCss": false,
"importSources": [
"./packages/react/src/create-strict-api/__tests__/__fixtures__/strict-api",
"@fixture/strict-api-test"
]
}
]
]
9 changes: 9 additions & 0 deletions fixtures/strict-api-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@fixture/strict-api-test",
"version": "0.1.0",
"private": true,
"main": "./src/index.ts",
"dependencies": {
"@compiled/react": "*"
}
}
12 changes: 12 additions & 0 deletions fixtures/strict-api-test/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createStrictAPI } from '@compiled/react';

const { css, XCSSProp, cssMap, cx } = createStrictAPI<{
'&:hover': {
color: 'var(--ds-text-hover)';
background: 'var(--ds-surface-hover)' | 'var(--ds-surface-sunken-hover)';
};
color: 'var(--ds-text)';
background: 'var(--ds-surface)' | 'var(--ds-surface-sunken)';
}>();

export { css, XCSSProp, cssMap, cx };
14 changes: 14 additions & 0 deletions packages/babel-plugin-strip-runtime/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# @compiled/babel-plugin-strip-runtime

## 0.25.0

### Minor Changes

- fbc17ed3: - `@compiled/babel-plugin-strip-runtime`: Fix `css` function calls not being extracted when using classic JSX pragma syntax and `@babel/preset-react` is turned on. Now, when the classic JSX pragma syntax is used for Compiled and `@babel/preset-react` is turned on (assuming `@babel/preset-react` runs before `@compiled/babel-plugin-strip-runtime`), the JSX pragma and the `jsx` import will be completely removed in the output.
- `@compiled/eslint-plugin`: Change regex in `jsx-pragma` rule to match @babel/plugin-transform-react-jsx
- `@compiled/utils`: Change regex in `jsx-pragma` rule to match @babel/plugin-transform-react-jsx

### Patch Changes

- Updated dependencies [fbc17ed3]
- @compiled/utils@0.9.0
- @compiled/css@0.12.1

## 0.23.0

### Minor Changes
6 changes: 3 additions & 3 deletions packages/babel-plugin-strip-runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@compiled/babel-plugin-strip-runtime",
"version": "0.23.0",
"version": "0.25.0",
"description": "A familiar and performant compile time CSS-in-JS library for React.",
"homepage": "https://compiledcssinjs.com/docs/pkg-babel-plugin-strip-runtime",
"bugs": "https://github.com/atlassian-labs/compiled/issues/new?assignees=&labels=bug&template=bug_report.md",
@@ -24,8 +24,8 @@
"@babel/template": "^7.20.7",
"@babel/traverse": "^7.23.2",
"@babel/types": "^7.21.5",
"@compiled/css": "^0.12.0",
"@compiled/utils": "^0.8.0"
"@compiled/css": "^0.12.1",
"@compiled/utils": "^0.9.0"
},
"devDependencies": {
"@compiled/babel-plugin": "*",
Original file line number Diff line number Diff line change
@@ -247,6 +247,194 @@ describe('babel-plugin-strip-runtime using source code', () => {
);
});
});

describe('with jsx pragma', () => {
it('work with classic jsx pragma', () => {
const codeWithPragma = `
/** @jsx myJsx */
import { css, jsx as myJsx } from '@compiled/react';
const Component = () => (
<div css={{ fontSize: 12, color: 'blue' }}>
hello world 2
</div>
);
const Component2 = () => (
<div css={css({ fontSize: 12, color: 'pink' })}>
hello world 2
</div>
);
`;

const actual = transform(codeWithPragma, {
run: 'both',
runtime: 'classic',
});

expect(actual).toMatchInlineSnapshot(`
"/* app.tsx generated by @compiled/babel-plugin v0.0.0 */
import * as React from 'react';
import { ax, ix } from '@compiled/react/runtime';
const Component = () =>
/*#__PURE__*/ React.createElement(
'div',
{
className: ax(['_1wyb1fwx _syaz13q2']),
},
'hello world 2'
);
const Component2 = () =>
/*#__PURE__*/ React.createElement(
'div',
{
className: ax(['_1wyb1fwx _syaz32ev']),
},
'hello world 2'
);
"
`);
});

it('work with automatic jsx pragma', () => {
const codeWithPragma = `
/** @jsxImportSource @compiled/react */
import { css } from '@compiled/react';
const Component = () => (
<div css={{ fontSize: 12, color: 'blue' }}>
hello world 2
</div>
);
const Component2 = () => (
<div css={css({ fontSize: 12, color: 'pink' })}>
hello world 2
</div>
);
`;

const actual = transform(codeWithPragma, {
run: 'both',
runtime: 'automatic',
});

expect(actual).toMatchInlineSnapshot(`
"/* app.tsx generated by @compiled/babel-plugin v0.0.0 */
import { ax, ix } from '@compiled/react/runtime';
import { jsxs as _jsxs } from '@compiled/react/jsx-runtime';
import { jsx as _jsx } from '@compiled/react/jsx-runtime';
/** @jsxImportSource @compiled/react */
const Component = () =>
_jsx('div', {
className: ax(['_1wyb1fwx _syaz13q2']),
children: 'hello world 2',
});
const Component2 = () =>
_jsx('div', {
className: ax(['_1wyb1fwx _syaz32ev']),
children: 'hello world 2',
});
"
`);
});

it('work with classic jsx pragma with extractStylesToDirectory', () => {
const codeWithPragma = `
/** @jsx myJsx */
import { css, jsx as myJsx } from '@compiled/react';
const Component = () => (
<div css={{ fontSize: 12, color: 'blue' }}>
hello world 2
</div>
);
const Component2 = () => (
<div css={css({ fontSize: 12, color: 'pink' })}>
hello world 2
</div>
);
`;

const actual = transform(codeWithPragma, {
run: 'both',
runtime: 'classic',
extractStylesToDirectory: { source: 'src/', dest: 'dist/' },
});

expect(actual).toMatchInlineSnapshot(`
"/* app.tsx generated by @compiled/babel-plugin v0.0.0 */
import './app.compiled.css';
import * as React from 'react';
import { ax, ix } from '@compiled/react/runtime';
const Component = () =>
/*#__PURE__*/ React.createElement(
'div',
{
className: ax(['_1wyb1fwx _syaz13q2']),
},
'hello world 2'
);
const Component2 = () =>
/*#__PURE__*/ React.createElement(
'div',
{
className: ax(['_1wyb1fwx _syaz32ev']),
},
'hello world 2'
);
"
`);
});

it('work with automatic jsx pragma with extractStylesToDirectory', () => {
const codeWithPragma = `
/** @jsxImportSource @compiled/react */
import { css } from '@compiled/react';
const Component = () => (
<div css={{ fontSize: 12, color: 'blue' }}>
hello world 2
</div>
);
const Component2 = () => (
<div css={css({ fontSize: 12, color: 'pink' })}>
hello world 2
</div>
);
`;

const actual = transform(codeWithPragma, {
run: 'both',
runtime: 'automatic',
extractStylesToDirectory: { source: 'src/', dest: 'dist/' },
});

expect(actual).toMatchInlineSnapshot(`
"/* app.tsx generated by @compiled/babel-plugin v0.0.0 */
import './app.compiled.css';
import { ax, ix } from '@compiled/react/runtime';
import { jsxs as _jsxs } from '@compiled/react/jsx-runtime';
import { jsx as _jsx } from '@compiled/react/jsx-runtime';
/** @jsxImportSource @compiled/react */
const Component = () =>
_jsx('div', {
className: ax(['_1wyb1fwx _syaz13q2']),
children: 'hello world 2',
});
const Component2 = () =>
_jsx('div', {
className: ax(['_1wyb1fwx _syaz32ev']),
children: 'hello world 2',
});
"
`);
});
});
});

describe('when run in subsequent steps', () => {
@@ -257,14 +445,13 @@ describe('babel-plugin-strip-runtime using source code', () => {
const baked = transform(code, { run: 'bake', runtime });
const actual = transform(baked, { run: 'extract', runtime });

// TODO: This is missing the PURE pragma in the Component return. Fix this.
expect(actual).toMatchInlineSnapshot(`
"/* app.tsx generated by @compiled/babel-plugin v0.0.0 */
import { ax, ix } from '@compiled/react/runtime';
import { jsxs as _jsxs } from 'react/jsx-runtime';
import { jsx as _jsx } from 'react/jsx-runtime';
const Component = () =>
_jsx('div', {
/*#__PURE__*/ _jsx('div', {
className: ax(['_1wyb1fwx _syaz13q2']),
children: 'hello world',
});
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ describe('babel-plugin-strip-runtime using transpiled code', () => {

expect(actual.split('var Component = ')[1]).toMatchInlineSnapshot(`
"() =>
(0, _jsxRuntime.jsx)('div', {
/*#__PURE__*/ (0, _jsxRuntime.jsx)('div', {
className: (0, _runtime.ax)(['_1wyb1fwx _syaz13q2']),
children: 'hello world',
});
@@ -114,7 +114,7 @@ describe('babel-plugin-strip-runtime using transpiled code', () => {
import { jsxs as _jsxs } from 'react/jsx-runtime';
import { jsx as _jsx } from 'react/jsx-runtime';
var Component = () =>
_jsx('div', {
/*#__PURE__*/ _jsx('div', {
className: ax(['_1wyb1fwx _syaz13q2']),
children: 'hello world',
});
@@ -150,7 +150,7 @@ describe('babel-plugin-strip-runtime using transpiled code', () => {

expect(actual.split('var Component = ')[1]).toMatchInlineSnapshot(`
"() =>
React.createElement(
/*#__PURE__*/ React.createElement(
'div',
{
className: (0, _runtime.ax)(['_1wyb1fwx _syaz13q2']),
@@ -169,7 +169,7 @@ describe('babel-plugin-strip-runtime using transpiled code', () => {
import * as React from 'react';
import { ax, ix } from '@compiled/react/runtime';
var Component = () =>
React.createElement(
/*#__PURE__*/ React.createElement(
'div',
{
className: ax(['_1wyb1fwx _syaz13q2']),
Loading