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.8
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.9
Choose a head ref
  • 9 commits
  • 35 files changed
  • 4 contributors

Commits on Dec 29, 2023

  1. Fix @compiled/babel-plugin handling of classic JSX pragma (#1603)

    * Fix @compiled/babel-plugin handling of classic JSX pragma
    
    * Remove `/** @jsx jsx */` and `/** @jsxImportSource @compiled/react */` comments through Compiled babel plugin
    
    * Throw error when jsx classic pragma is set in Babel config, or if Compiled APIs and Emotion JSX pragma were mixed in the same file (this would otherwise cause invalid output)
    
    * Refactor `@compiled/babel-plugin-strip-runtime` tests
    dddlr authored Dec 29, 2023
    Copy the full SHA
    df91c60 View commit details
  2. Version Packages (#1609)

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

Commits on Jan 4, 2024

  1. Option to increase specificity of generated styles to enable XCSSProp…

    … migration (#1608)
    
    * fix: fixes types for atomic css plugin
    
    * feat: add spike for increasing specificity of generated styles
    
    * feat: wire up increase specificity
    
    * chore: update jsdoc
    
    * chore: changeset
    
    * chore: turn on increased specificity
    
    * fix: edge case with psuedo elements
    
    * fix: use selector parser
    
    * fix: apply to compiled class names only
    itsdouges authored Jan 4, 2024
    Copy the full SHA
    5bd1b49 View commit details
  2. Version Packages (#1611)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    atlas-dst-bot and github-actions[bot] authored Jan 4, 2024
    Copy the full SHA
    f863161 View commit details

Commits on Jan 10, 2024

  1. Fix Compiled throwing when multiple API imports exist in the same mod…

    …ule (#1612)
    
    * fix: multiple compiled imports not working with each other
    
    * chore: changeset
    itsdouges authored Jan 10, 2024
    Copy the full SHA
    3567585 View commit details

Commits on Jan 11, 2024

  1. Version Packages (#1615)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    atlas-dst-bot and github-actions[bot] authored Jan 11, 2024
    Copy the full SHA
    272dac0 View commit details

Commits on Jan 23, 2024

  1. Fix typo in no-invalid-css-map README (#1616)

    * Fix typo in no-invalid-css-map README
    
    * Fix tokens
    dddlr authored Jan 23, 2024
    Copy the full SHA
    fd6dc70 View commit details
  2. Fix r18 JSX namespace types (#1617)

    * fix: fixes r18 types
    
    * chore: changeset
    itsdouges authored Jan 23, 2024
    Copy the full SHA
    541ab19 View commit details
  3. Version Packages (#1618)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    atlas-dst-bot and github-actions[bot] authored Jan 23, 2024
    Copy the full SHA
    da6fc56 View commit details
Showing with 1,065 additions and 564 deletions.
  1. +1 −0 .storybook/.babelrc.json
  2. +11 −0 packages/babel-plugin-strip-runtime/CHANGELOG.md
  3. +1 −1 packages/babel-plugin-strip-runtime/package.json
  4. +166 −0 packages/babel-plugin-strip-runtime/src/__tests__/extract-styles.test.ts
  5. +360 −0 packages/babel-plugin-strip-runtime/src/__tests__/jsx-pragma.test.ts
  6. +1 −393 packages/babel-plugin-strip-runtime/src/__tests__/strip-runtime-source-code.test.ts
  7. +67 −0 packages/babel-plugin-strip-runtime/src/__tests__/transform.ts
  8. +1 −51 packages/babel-plugin-strip-runtime/src/index.ts
  9. +0 −40 packages/babel-plugin-strip-runtime/src/utils/get-jsx-pragma.ts
  10. +25 −0 packages/babel-plugin/CHANGELOG.md
  11. +2 −2 packages/babel-plugin/package.json
  12. +110 −27 packages/babel-plugin/src/babel-plugin.ts
  13. +2 −1 packages/babel-plugin/src/class-names/index.ts
  14. +2 −2 packages/babel-plugin/src/css-prop/__tests__/jsx-pragma.test.ts
  15. +4 −4 packages/babel-plugin/src/styled/index.ts
  16. +16 −5 packages/babel-plugin/src/types.ts
  17. +9 −7 packages/babel-plugin/src/utils/is-compiled.ts
  18. +23 −0 packages/babel-plugin/src/utils/is-jsx-function.ts
  19. +2 −1 packages/babel-plugin/src/xcss-prop/__tests__/transformation.test.ts
  20. +6 −0 packages/css/CHANGELOG.md
  21. +1 −1 packages/css/package.json
  22. +62 −5 packages/css/src/__tests__/transform.test.ts
  23. +79 −0 packages/css/src/plugins/__tests__/increase-specificity.test.ts
  24. +7 −10 packages/css/src/plugins/atomicify-rules.ts
  25. +41 −0 packages/css/src/plugins/increase-specificity.ts
  26. +5 −2 packages/css/src/transform.ts
  27. +5 −5 packages/eslint-plugin/src/rules/no-invalid-css-map/README.md
  28. +8 −0 packages/parcel-transformer/CHANGELOG.md
  29. +3 −3 packages/parcel-transformer/package.json
  30. +6 −0 packages/react/CHANGELOG.md
  31. +1 −1 packages/react/package.json
  32. +23 −0 packages/react/src/create-strict-api/__tests__/mixed.test.tsx
  33. +4 −0 packages/react/src/jsx/jsx-local-namespace.ts
  34. +8 −0 packages/webpack-loader/CHANGELOG.md
  35. +3 −3 packages/webpack-loader/package.json
1 change: 1 addition & 0 deletions .storybook/.babelrc.json
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
{
"importReact": false,
"optimizeCss": false,
"increaseSpecificity": true,
"transformerBabelPlugins": [
[
"@babel/plugin-proposal-decorators",
11 changes: 11 additions & 0 deletions packages/babel-plugin-strip-runtime/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @compiled/babel-plugin-strip-runtime

## 0.28.0

### Minor Changes

- df91c60f: \[BREAKING\] Fix @compiled/babel-plugin handling of classic JSX pragma. Involves several breaking changes.

- Move the below @compiled/babel-plugin-strip-runtime behaviour to @compiled/babel-plugin
- Classic JSX pragma will no longer affect the Babel output: instead of seeing `jsx` function calls in the output, you will see `React.createElement` calls again. (Added to @compiled/babel-plugin-strip-runtime in v0.27.0)
- @compiled/babel-plugin: Due to the above behaviour change, a classic JSX pragma (`/** @jsx jsx */`) is used, React will always be imported regardless of the value of `importReact`.
- @compiled/babel-plugin: We don't support specifying the `pragma` option through `@babel/preset-react` or `@babel/plugin-transform-react-jsx` - we will now throw an error if this happens.

## 0.27.0

### Minor Changes
2 changes: 1 addition & 1 deletion 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.27.0",
"version": "0.28.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",
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
import { writeFileSync } from 'fs';

import { transform } from './transform';

// Mock out FS to avoid writing to disk
// We aren't processing the result anyway, so no need for specifying the response
jest.mock('fs');

describe('babel-plugin-strip-runtime with stylesheet extraction (extractStylesToDirectory)', () => {
describe('with the classic runtime', () => {
const runtime = 'classic';

describe('without JSX pragma', () => {
const code = `
import '@compiled/react';
const Component = () => (
<div css={{ fontSize: 12, color: 'blue' }}>
hello world
</div>
);
`;

it('adds styles to directory', () => {
const actual = transform(code, {
run: 'both',
runtime,
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'
);
"
`);

expect(writeFileSync).toBeCalledWith(
expect.stringContaining('app.compiled.css'),
'._1wyb1fwx{font-size:12px}\n._syaz13q2{color:blue}'
);
});

it('error when source directory is not found', () => {
expect(() =>
transform(code, {
run: 'both',
runtime,
extractStylesToDirectory: { source: 'not-existing-src/', dest: 'dist/' },
})
).toThrowWithMessage(
Error,
`/base/src/app.tsx: Source directory 'not-existing-src/' was not found relative to source file ('../src/app.tsx')`
);
});
});

describe('with JSX pragma', () => {
it('extracts styles into app.compiled.css', () => {
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'
);
"
`);
});
});
});

describe('with the automatic runtime', () => {
describe('with JSX pragma', () => {
it('extracts styles into app.compiled.css', () => {
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 'react/jsx-runtime';
import { jsx as _jsx } from 'react/jsx-runtime';
const Component = () =>
/*#__PURE__*/ _jsx('div', {
className: ax(['_1wyb1fwx _syaz13q2']),
children: 'hello world 2',
});
const Component2 = () =>
/*#__PURE__*/ _jsx('div', {
className: ax(['_1wyb1fwx _syaz32ev']),
children: 'hello world 2',
});
"
`);
});
});
});
});
Loading