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.5
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.6
Choose a head ref
  • 8 commits
  • 32 files changed
  • 7 contributors

Commits on Dec 11, 2023

  1. Fix Compiled runtime being added unexpectedly for xcss prop usage (#1588

    )
    
    * fix: fixes xcss prop usage importing unexpected compiled runtime
    
    * chore: changeset
    
    * chore: update test names
    
    * chore: remove new line
    itsdouges authored Dec 11, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    a9509cc View commit details
  2. Version Packages (#1589)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    atlas-dst-bot and github-actions[bot] authored Dec 11, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    dd5e81d View commit details

Commits on Dec 12, 2023

  1. Fix no-empty-styled-expression rule that's linting false positives (#…

    …1590)
    
    * Added false positive test cases
    
    * Fixed bug that linted against normal empty function calls
    
    * Added test egde cases and removed redundant code
    
    * Removed double callee type checking
    
    * Added changeset
    
    * Renamed variable name to be more descriptive
    
    * Generalise test function calls
    
    * Fixed indentation for tests
    
    * Fixed eslint rule declaration typo (#1578)
    
    * fixed the typo from eslint entry point
    
    * Added patch changeset for typo bug
    
    * Version Packages (#1580)
    
    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    
    * Revert/revert jsx pragma change (#1583)
    
    * Revert "Fix jsx pragma breaking @compiled/babel-plugin-strip-runtime stylesheet extraction (#1557)"
    
    This reverts commit fbc17ed.
    
    * Add changeset
    
    * Block invalid properties on the strict API `cssMap` when extended type was met. (#1582)
    
    * Block invalid properties on `cssMap` when extended type was met.
    
    Previously, `asdf` in this example would never error because part of the interface existed, so this was "extended", eg. `{ color: …, asdf: … }` extends `{ color: … }` was true.
    
    So instead of using the inferred generic `TStyles extends …` to enforce, we enforce the type explicitly, and use the inferred generic `TStyles` to build our output type.  This maintains the proper output type while blocking the input type.
    
    More easily visualized in the playground:
    
     - Before: [TS Playground](https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBDAnmApnAVHAhgZzgYQGVC4AzKCEOAcgGMcclVqBuAKDZQA9JYFk0RQgAUcKAK4ATCHgC8bOHAA+NAGQAudVlIwUUaguVrNAIyy0A1pIpgDildQ3qTKUtBR2jjzbXEfDDk6+KAC0UCgA5sAQAHaegZqkwFCMIQA2KDC6+gHG6kkpMOnAMf72eRFQWCAgWFAhehQ55d7qtVAWevF5YGnmKAAWEGmSXbmtYhm0MNFx4044qGlpJRENUE3drTB1EZkhulwwW04AbsAoAO4HVTE4wDOxJ1rTwKdlXhpY4jAQScvPEx9GIWZ60AYoSwoSTPUakb5pY7zdRwkrQ2HAHBYIHo5EocBIZ4oGLYjIw5EFRjPNy+HDUiC0kLne44+mMy4PAYlaniZY4WjhYnPIbvZqfdQlMJYGJ7Z4lUbZEAlLC6OUxU5YFbkloaDI6Z4rEEGhma4pG5EQMCPElpZ4QH4hP5SmUfBJgb5ibXisDAabicIhSU+v3hZ69fpDEZ6EI4IaXOY69ThxCrZ7hLCSR0xNKINMoDMhS5QB6u4zhACO4mSuMTxYiAyRiZ2UD2jfF4jE9RKGq1zw70Z7wC9CUHw+MzJLMPYHG4vHgTEExGENj0MxQcjgACV89Js4gADxCAB0y8tq4uOH3jGLMqMMXEIBcUAAfM-pwuCJQfWTCOD8Vg4FkOBCBgYtpiEU9UFgC84FUOBRAkaQcAAEUhPoqmtHBp1naB5wEYDQN9GAIJXaD10Arcd1iHND2II8QOlSQ6kkSDz3IuDj0IU4IlYsicDfDgPwQqQZFQ2h0JVWYNwAb0MABtABF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gBZYQAEkABkrOQy7hE3dzhCszdXIATUu5CrPwZ6AEFNzB1zHvcgA5S7NysgAxX6rNh-ArKB9zLth9zXMugB1TdHtczHkMexH8Fc57Acu6hNL00C-FW7CeFw-hUE-LafyQDJL1m3z-KAwK4EU0LwpQSLSCK2LpgZmW5sU8rKpSvBt1qqB6uvVYWraiwOq6nrCs279oRAxA+dG2X5oUzTJumrnTZY4zEH2upJNiI6TpiByWY4Wq7ngAV810Ci3OG2oKqOKq8BN7bJAjrBnwACgASkA-yRcUUg2teWI4HoHA7qwMA4H3Hqptc82+aj5LqvVuqGpvCIWpAgySLPPjYPg9SkLdjCpO7gboCG3KsHDsfXx6lOK96xgLfXPSG81pudf0oiO6gkzu+Evu0PdzCh9skfHLHw8spy5yk-txRU70rOprgdNdxzUWQpU9Lpar3n13luOeYXvzau64JrsCmmZOAD8poAHpoFwAAAIwBwA0Hgvl1hNDgCEEIcBLgDBVCgUUs9FDhBgP6MK88+ZgN6mZDgU0SFkMgQXBgxdS40Jof7WIjBGGFxYXACBQFg74P3A-WqaRoB6WoBqKAycsGpQOElVO1Amo9W8CKLo98C7DHETQKRMiQhyMOEUNRUBFF8PMinVO04A5cIoSgXhAjmEl2Tg-DqpR75EM0WIqAEjdGyOQYYxRyjH69VURAUU1ANGiO0ZIuoeiDFJRCMY0xZkgnBOMB1GAyd8jJFSOCbKkh1AZKyZSIoeSRip0UZErR3iaDhBhHw1JwTHBwH8iYH4vw4hVK8RIoEfhqBmPAeZVOQA)
    
    * Fix strictly scoped test and extend to the `css()` call as well.
    
     - The `expect(getByTestId('div')).toHaveCompiledCss('bkgrnd', 'red');` was wrong.
     - Adds this to `css()` calls to ensure we don't regress in the future.
    
    * Minimize repetition of `TSchema` styles and update generic on `cssMap` to be distinct.
    
    * Split our "invalid css property" test into multiple call sites to test different variants.
    
    ---------
    
    Co-authored-by: Jake Lane <jlane2@atlassian.com>
    
    * Fix size-limit (#1586)
    
    * Version Packages (#1584)
    
    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    
    * Fix Compiled runtime being added unexpectedly for xcss prop usage (#1588)
    
    * fix: fixes xcss prop usage importing unexpected compiled runtime
    
    * chore: changeset
    
    * chore: update test names
    
    * chore: remove new line
    
    * Version Packages (#1589)
    
    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    
    ---------
    
    Co-authored-by: atlas-dst-bot <81662413+atlas-dst-bot@users.noreply.github.com>
    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    Co-authored-by: Jake Lane <jlane2@atlassian.com>
    Co-authored-by: Kylor Hall <136543114+kylorhall-atlassian@users.noreply.github.com>
    Co-authored-by: Michael Dougall <6801309+itsdouges@users.noreply.github.com>
    6 people authored Dec 12, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    6dfb0cd View commit details
  2. Version Packages (#1591)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    atlas-dst-bot and github-actions[bot] authored Dec 12, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1ed6f73 View commit details

Commits on Dec 18, 2023

  1. Fix #1557 breaking Emotion usages (#1585)

    * Fix jsx pragma breaking @compiled/babel-plugin-strip-runtime stylesheet extraction (#1557)
    
    * Fix Compiled babel plugin not being compatible with Emotion
    
    * Add tests to ensure support for Emotion
    
    * Add changeset
    
    * Fix prettier issue
    dddlr authored Dec 18, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    db572d4 View commit details
  2. Version Packages (#1595)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    atlas-dst-bot and github-actions[bot] authored Dec 18, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e2d1e4d View commit details
  3. Fix XCSSProp types (#1596)

    * fix: resolve cssMap from strict api having its generic output type unset
    
    * chore: add more tests
    
    * chore: changeset
    
    * chore: fix test
    
    * Update expert error location in test
    
    Co-authored-by: Kylor Hall <136543114+kylorhall-atlassian@users.noreply.github.com>
    
    * chore: fix comment
    
    ---------
    
    Co-authored-by: Kylor Hall <136543114+kylorhall-atlassian@users.noreply.github.com>
    itsdouges and kylorhall-atlassian authored Dec 18, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    34674ae View commit details
  4. Version Packages (#1597)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    atlas-dst-bot and github-actions[bot] authored Dec 18, 2023
    Copy the full SHA
    7c3dd20 View commit details
Showing with 704 additions and 75 deletions.
  1. +15 −0 packages/babel-plugin-strip-runtime/CHANGELOG.md
  2. +2 −2 packages/babel-plugin-strip-runtime/package.json
  3. +288 −2 packages/babel-plugin-strip-runtime/src/__tests__/strip-runtime-source-code.test.ts
  4. +4 −4 packages/babel-plugin-strip-runtime/src/__tests__/strip-runtime-transpiled-code.test.ts
  5. +62 −3 packages/babel-plugin-strip-runtime/src/index.ts
  6. +19 −16 packages/babel-plugin-strip-runtime/src/types.ts
  7. +40 −0 packages/babel-plugin-strip-runtime/src/utils/get-jsx-pragma.ts
  8. +3 −2 packages/babel-plugin-strip-runtime/src/utils/is-create-element.ts
  9. +6 −0 packages/babel-plugin/CHANGELOG.md
  10. +1 −1 packages/babel-plugin/package.json
  11. +2 −9 packages/babel-plugin/src/babel-plugin.ts
  12. +4 −12 packages/babel-plugin/src/xcss-prop/__tests__/transformation.test.ts
  13. +2 −0 packages/babel-plugin/src/xcss-prop/index.ts
  14. +18 −0 packages/eslint-plugin/CHANGELOG.md
  15. +2 −2 packages/eslint-plugin/package.json
  16. +23 −0 packages/eslint-plugin/src/rules/no-empty-styled-expression/__tests__/rule.test.ts
  17. +10 −4 packages/eslint-plugin/src/rules/no-empty-styled-expression/index.ts
  18. +12 −4 packages/eslint-plugin/src/utils/jsx.ts
  19. +1 −1 packages/eslint-plugin/tsconfig.json
  20. +8 −0 packages/parcel-transformer/CHANGELOG.md
  21. +3 −3 packages/parcel-transformer/package.json
  22. +2 −2 packages/parcel-transformer/src/__tests__/transformer.parceltest.ts
  23. +6 −0 packages/react/CHANGELOG.md
  24. +1 −1 packages/react/package.json
  25. +140 −0 packages/react/src/create-strict-api/__tests__/index.test.tsx
  26. +5 −3 packages/react/src/create-strict-api/index.ts
  27. +10 −0 packages/utils/CHANGELOG.md
  28. +1 −1 packages/utils/package.json
  29. +1 −0 packages/utils/src/index.ts
  30. +2 −0 packages/utils/src/jsx.ts
  31. +8 −0 packages/webpack-loader/CHANGELOG.md
  32. +3 −3 packages/webpack-loader/package.json
15 changes: 15 additions & 0 deletions packages/babel-plugin-strip-runtime/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# @compiled/babel-plugin-strip-runtime

## 0.27.0

### Minor Changes

- db572d43: - @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.
- The previous version of this PR caused a regression where using the classic JSX pragma `/** @jsx jsx */` with Emotion no longer worked; this is now fixed.
- @compiled/utils: Add JSX pragma regex (as used by `babel-plugin-transform-react-jsx`) directly to @compiled/utils
- @compiled/eslint-plugin: Use the official JSX pragma regex `/^\s*\*?\s*@jsx\s+([^\s]+)\s*$/m` instead of `/@jsx (\w+)/`; the former is used in `babel-plugin-transform-react-jsx`

### Patch Changes

- Updated dependencies [db572d43]
- @compiled/utils@0.9.2

## 0.26.2

### Patch Changes
4 changes: 2 additions & 2 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.26.2",
"version": "0.27.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",
@@ -25,7 +25,7 @@
"@babel/traverse": "^7.23.2",
"@babel/types": "^7.21.5",
"@compiled/css": "^0.12.1",
"@compiled/utils": "^0.9.1"
"@compiled/utils": "^0.9.2"
},
"devDependencies": {
"@compiled/babel-plugin": "*",
Original file line number Diff line number Diff line change
@@ -247,6 +247,293 @@ 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("doesn't do anything to emotion's classic jsx pragma", () => {
const codeWithPragma = `
/** @jsx myJsx */
import { css, jsx as myJsx } from '@emotion/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(`
"/** @jsx myJsx */
import { css, jsx as myJsx } from '@emotion/react';
const Component = () =>
myJsx(
'div',
{
css: {
fontSize: 12,
color: 'blue',
},
},
'hello world 2'
);
const Component2 = () =>
myJsx(
'div',
{
css: css({
fontSize: 12,
color: 'pink',
}),
},
'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("doesn't do anything to emotion's automatic jsx pragma", () => {
const codeWithPragma = `
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/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(`
"/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react';
import { jsx as _jsx } from '@emotion/react/jsx-runtime';
const Component = () =>
_jsx('div', {
css: {
fontSize: 12,
color: 'blue',
},
children: 'hello world 2',
});
const Component2 = () =>
_jsx('div', {
css: css({
fontSize: 12,
color: 'pink',
}),
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 +544,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