@compiled/react 0.10.1 → 0.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/browser/class-names/index.js.map +1 -1
  2. package/dist/browser/css/index.js.map +1 -1
  3. package/dist/browser/index.js.map +1 -1
  4. package/dist/browser/jsx/jsx-dev-runtime.js.map +1 -1
  5. package/dist/browser/jsx/jsx-local-namespace.js.map +1 -1
  6. package/dist/browser/jsx/jsx-runtime.js.map +1 -1
  7. package/dist/browser/keyframes/__fixtures__/index.js +1 -0
  8. package/dist/browser/keyframes/__fixtures__/index.js.map +1 -1
  9. package/dist/browser/keyframes/index.js.map +1 -1
  10. package/dist/browser/runtime/ax.js.map +1 -1
  11. package/dist/browser/runtime/cache.d.ts +12 -0
  12. package/dist/browser/runtime/cache.js +15 -0
  13. package/dist/browser/runtime/cache.js.flow +18 -0
  14. package/dist/browser/runtime/cache.js.map +1 -0
  15. package/dist/browser/runtime/css-custom-property.js.map +1 -1
  16. package/dist/browser/runtime/dev-warnings.js +10 -6
  17. package/dist/browser/runtime/dev-warnings.js.map +1 -1
  18. package/dist/browser/runtime/index.js.map +1 -1
  19. package/dist/browser/runtime/is-node.js +1 -3
  20. package/dist/browser/runtime/is-node.js.map +1 -1
  21. package/dist/browser/runtime/sheet.js +5 -1
  22. package/dist/browser/runtime/sheet.js.map +1 -1
  23. package/dist/browser/runtime/style-cache.js +4 -0
  24. package/dist/browser/runtime/style-cache.js.map +1 -1
  25. package/dist/browser/runtime/types.js.map +1 -1
  26. package/dist/browser/runtime.js.map +1 -1
  27. package/dist/browser/styled/index.js.map +1 -1
  28. package/dist/browser/types.js.map +1 -1
  29. package/dist/browser/utils/error.js.map +1 -1
  30. package/dist/cjs/class-names/index.js +1 -1
  31. package/dist/cjs/class-names/index.js.map +1 -1
  32. package/dist/cjs/css/index.js +1 -1
  33. package/dist/cjs/css/index.js.map +1 -1
  34. package/dist/cjs/index.js.map +1 -1
  35. package/dist/cjs/jsx/jsx-dev-runtime.js +5 -1
  36. package/dist/cjs/jsx/jsx-dev-runtime.js.map +1 -1
  37. package/dist/cjs/jsx/jsx-local-namespace.js.map +1 -1
  38. package/dist/cjs/jsx/jsx-runtime.js +5 -1
  39. package/dist/cjs/jsx/jsx-runtime.js.map +1 -1
  40. package/dist/cjs/keyframes/__fixtures__/index.js +2 -1
  41. package/dist/cjs/keyframes/__fixtures__/index.js.map +1 -1
  42. package/dist/cjs/keyframes/index.js +1 -1
  43. package/dist/cjs/keyframes/index.js.map +1 -1
  44. package/dist/cjs/runtime/ax.js.map +1 -1
  45. package/dist/cjs/runtime/cache.d.ts +12 -0
  46. package/dist/cjs/runtime/cache.js +19 -0
  47. package/dist/cjs/runtime/cache.js.flow +18 -0
  48. package/dist/cjs/runtime/cache.js.map +1 -0
  49. package/dist/cjs/runtime/css-custom-property.js.map +1 -1
  50. package/dist/cjs/runtime/dev-warnings.js +10 -6
  51. package/dist/cjs/runtime/dev-warnings.js.map +1 -1
  52. package/dist/cjs/runtime/index.js.map +1 -1
  53. package/dist/cjs/runtime/is-node.js +1 -3
  54. package/dist/cjs/runtime/is-node.js.map +1 -1
  55. package/dist/cjs/runtime/sheet.js +6 -2
  56. package/dist/cjs/runtime/sheet.js.map +1 -1
  57. package/dist/cjs/runtime/style-cache.js +15 -7
  58. package/dist/cjs/runtime/style-cache.js.map +1 -1
  59. package/dist/cjs/runtime/style.js +9 -5
  60. package/dist/cjs/runtime/style.js.map +1 -1
  61. package/dist/cjs/runtime/types.js.map +1 -1
  62. package/dist/cjs/runtime.js.map +1 -1
  63. package/dist/cjs/styled/index.js +1 -1
  64. package/dist/cjs/styled/index.js.map +1 -1
  65. package/dist/cjs/types.js.map +1 -1
  66. package/dist/cjs/utils/error.js.map +1 -1
  67. package/dist/esm/class-names/index.js.map +1 -1
  68. package/dist/esm/css/index.js.map +1 -1
  69. package/dist/esm/index.js.map +1 -1
  70. package/dist/esm/jsx/jsx-dev-runtime.js.map +1 -1
  71. package/dist/esm/jsx/jsx-local-namespace.js.map +1 -1
  72. package/dist/esm/jsx/jsx-runtime.js.map +1 -1
  73. package/dist/esm/keyframes/__fixtures__/index.js +1 -0
  74. package/dist/esm/keyframes/__fixtures__/index.js.map +1 -1
  75. package/dist/esm/keyframes/index.js.map +1 -1
  76. package/dist/esm/runtime/ax.js.map +1 -1
  77. package/dist/esm/runtime/cache.d.ts +12 -0
  78. package/dist/esm/runtime/cache.js +15 -0
  79. package/dist/esm/runtime/cache.js.flow +18 -0
  80. package/dist/esm/runtime/cache.js.map +1 -0
  81. package/dist/esm/runtime/css-custom-property.js.map +1 -1
  82. package/dist/esm/runtime/dev-warnings.js +10 -6
  83. package/dist/esm/runtime/dev-warnings.js.map +1 -1
  84. package/dist/esm/runtime/index.js.map +1 -1
  85. package/dist/esm/runtime/is-node.js +1 -3
  86. package/dist/esm/runtime/is-node.js.map +1 -1
  87. package/dist/esm/runtime/sheet.js +5 -1
  88. package/dist/esm/runtime/sheet.js.map +1 -1
  89. package/dist/esm/runtime/style-cache.js +4 -0
  90. package/dist/esm/runtime/style-cache.js.map +1 -1
  91. package/dist/esm/runtime/types.js.map +1 -1
  92. package/dist/esm/runtime.js.map +1 -1
  93. package/dist/esm/styled/index.js.map +1 -1
  94. package/dist/esm/types.js.map +1 -1
  95. package/dist/esm/utils/error.js.map +1 -1
  96. package/package.json +15 -12
  97. package/src/__tests__/browser.test.tsx +1 -6
  98. package/src/__tests__/{display-names.test.tsx → display-names.test.ts} +1 -0
  99. package/src/__tests__/jest-matcher.test.tsx +2 -0
  100. package/src/__tests__/ssr.test.tsx +2 -0
  101. package/src/class-names/__tests__/index.test.tsx +1 -0
  102. package/src/class-names/{index.tsx → index.ts} +0 -0
  103. package/src/css/__tests__/index.test.tsx +1 -0
  104. package/src/css/{index.tsx → index.ts} +0 -0
  105. package/src/{index.tsx → index.ts} +0 -0
  106. package/src/jsx/__tests__/jsx-pragma.test.tsx +1 -0
  107. package/src/jsx/{jsx-dev-runtime.tsx → jsx-dev-runtime.ts} +0 -0
  108. package/src/jsx/{jsx-local-namespace.tsx → jsx-local-namespace.ts} +0 -0
  109. package/src/jsx/{jsx-runtime.tsx → jsx-runtime.ts} +0 -0
  110. package/src/keyframes/__fixtures__/{index.tsx → index.ts} +1 -0
  111. package/src/keyframes/__tests__/index.test.tsx +18 -5
  112. package/src/keyframes/{index.tsx → index.ts} +0 -0
  113. package/src/runtime/__perf__/cs.test.tsx +137 -92
  114. package/src/runtime/__perf__/utils/cs.tsx +15 -15
  115. package/src/runtime/__perf__/utils/{sheet.tsx → sheet.ts} +0 -0
  116. package/src/runtime/__tests__/{ax.test.tsx → ax.test.ts} +0 -0
  117. package/src/runtime/__tests__/{css-custom-property.test.tsx → css-custom-property.test.ts} +0 -0
  118. package/src/runtime/__tests__/style-ssr.test.tsx +4 -0
  119. package/src/runtime/__tests__/style.test.tsx +0 -4
  120. package/src/runtime/{ax.tsx → ax.ts} +0 -0
  121. package/src/runtime/cache.js.flow +18 -0
  122. package/src/runtime/cache.ts +14 -0
  123. package/src/runtime/{css-custom-property.tsx → css-custom-property.ts} +0 -0
  124. package/src/runtime/{dev-warnings.tsx → dev-warnings.ts} +0 -0
  125. package/src/runtime/{index.tsx → index.ts} +0 -0
  126. package/src/runtime/{is-node.tsx → is-node.ts} +1 -2
  127. package/src/runtime/{sheet.tsx → sheet.ts} +7 -1
  128. package/src/runtime/style-cache.tsx +5 -0
  129. package/src/runtime/{types.tsx → types.ts} +0 -0
  130. package/src/{runtime.tsx → runtime.ts} +0 -0
  131. package/src/styled/__tests__/index.test.tsx +1 -0
  132. /package/src/styled/{index.tsx → index.ts} +0 -0
  133. /package/src/{types.tsx → types.ts} +0 -0
  134. /package/src/utils/{error.tsx → error.ts} +0 -0
@@ -1,4 +1,5 @@
1
1
  /** @jsxImportSource @compiled/react */
2
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
3
  import { keyframes, styled } from '@compiled/react';
3
4
  import { render } from '@testing-library/react';
4
5
 
@@ -7,15 +8,27 @@ import defaultFadeOut, { namedFadeOut, fadeOut as shadowedFadeOut } from '../__f
7
8
  const getOpacity = (str: string | number) => str;
8
9
 
9
10
  const getKeyframe = (name: string) => {
10
- const styles = Array.from(
11
- document.body.querySelectorAll('style'),
12
- (style) => style.innerHTML
13
- ).join('\n');
11
+ const searchStr = `@keyframes ${name}`;
14
12
 
15
- return styles.substring(styles.indexOf(`@keyframes ${name}`));
13
+ return Array.from(document.head.querySelectorAll('style'), (style) => style.innerHTML)
14
+ .filter((style) => style.indexOf(searchStr) >= 0)
15
+ .map((style) => style.substring(style.indexOf(searchStr)))
16
+ .join('\n');
16
17
  };
17
18
 
18
19
  describe('keyframes', () => {
20
+ beforeAll(() => {
21
+ process.env.CACHE = 'false';
22
+ });
23
+
24
+ afterAll(() => {
25
+ delete process.env.CACHE;
26
+ });
27
+
28
+ afterEach(() => {
29
+ document.head.innerHTML = '';
30
+ });
31
+
19
32
  describe('referenced through a css prop', () => {
20
33
  describe('render an animation', () => {
21
34
  it('given an object call expression argument', () => {
File without changes
@@ -1,111 +1,156 @@
1
1
  import { runBenchmark } from '@compiled/benchmark';
2
+ import { JSDOM } from 'jsdom';
2
3
  import * as React from 'react';
4
+ import { memo } from 'react';
5
+ import { render } from 'react-dom';
3
6
  import { renderToString } from 'react-dom/server';
4
7
 
5
8
  import { CC, CS } from '../index';
6
9
 
7
- import { StyleArr, StyleStr } from './utils/cs';
10
+ const MemoCS = memo(CS, () => true);
11
+
12
+ import { StyleBucketFromArray, StyleBucketFromString } from './utils/cs';
8
13
 
9
14
  describe('CS benchmark', () => {
10
- it('completes with CS (1 array element) or StyleArr as the fastest', async () => {
11
- const stylesArr = [
12
- '._s7n4jp4b{vertical-align:top}',
13
- '._1reo15vq{overflow-x:hidden}',
14
- '._18m915vq{overflow-y:hidden}',
15
- '._1bto1l2s{text-overflow:ellipsis}',
16
- '._o5721q9c{white-space:nowrap}',
17
- '._ca0qidpf{padding-top:0}',
18
- '._u5f31y44{padding-right:4px}',
19
- '._n3tdidpf{padding-bottom:0}',
20
- '._19bv1y44{padding-left:4px}',
21
- '._p12f12xx{max-width:100px}',
22
- '._1bsb1osq{width:100%}',
23
- ];
15
+ describe.each(['server', 'client'])('on the %s', (env) => {
16
+ const document = globalThis.document;
17
+ const window = globalThis.window;
18
+
19
+ beforeAll(() => {
20
+ if (env === 'server') {
21
+ // @ts-expect-error
22
+ delete globalThis.document;
23
+ // @ts-expect-error
24
+ delete globalThis.window;
25
+ } else {
26
+ const dom = new JSDOM('<div id="root"></div>');
27
+ globalThis.document = dom.window.document;
28
+ // @ts-expect-error
29
+ globalThis.window = dom.window;
30
+ }
31
+ });
32
+
33
+ afterAll(() => {
34
+ globalThis.document = document;
35
+ globalThis.window = window;
36
+ });
37
+
38
+ const fastest =
39
+ env === 'server'
40
+ ? ['StyleBucketFromArray', 'StyleBucketFromString']
41
+ : ['MemoCS (1 array element)', 'MemoCS (n array elements)'];
24
42
 
25
- const stylesStr = stylesArr.join('');
43
+ it(`completes with [${fastest.join(', ')}] as the fastest`, async () => {
44
+ const stylesArr = [
45
+ '._s7n4jp4b{vertical-align:top}',
46
+ '._1reo15vq{overflow-x:hidden}',
47
+ '._18m915vq{overflow-y:hidden}',
48
+ '._1bto1l2s{text-overflow:ellipsis}',
49
+ '._o5721q9c{white-space:nowrap}',
50
+ '._ca0qidpf{padding-top:0}',
51
+ '._u5f31y44{padding-right:4px}',
52
+ '._n3tdidpf{padding-bottom:0}',
53
+ '._19bv1y44{padding-left:4px}',
54
+ '._p12f12xx{max-width:100px}',
55
+ '._1bsb1osq{width:100%}',
56
+ ];
26
57
 
27
- const className = [
28
- '_bfhk1jys',
29
- '_2rko1l7b',
30
- '_vchhusvi',
31
- '_syaz4rde',
32
- '_1e0c1o8l',
33
- '_1wyb1skh',
34
- '_k48p1fw0',
35
- '_vwz4kb7n',
36
- '_p12f1osq',
37
- '_ca0qyh40',
38
- '_u5f3idpf',
39
- '_n3td1l7b',
40
- '_19bvidpf',
41
- '_1p1dangw',
42
- '_s7n41q9y',
43
- ].join(' ');
58
+ const stylesStr = stylesArr.join('');
44
59
 
45
- const style = {
46
- '--_16owtcm': 'rgb(227, 252, 239)',
47
- '--_kmurgp': 'rgb(0, 102, 68)',
48
- } as any;
60
+ const className = stylesArr.map((rule) => rule.slice(1, 10)).join(' ');
61
+ const nonce = 'k0Mp1lEd';
49
62
 
50
- const nonce = 'k0Mp1lEd';
63
+ const renderJSX =
64
+ env === 'server'
65
+ ? (jsx: (key: number) => JSX.Element) => {
66
+ renderToString(<>{Array.from({ length: 10 }).map((_, i) => jsx(i))}</>);
67
+ }
68
+ : (jsx: (key: number) => JSX.Element) => {
69
+ render(
70
+ <>{Array.from({ length: 10 }).map((_, i) => jsx(i))}</>,
71
+ globalThis.document.getElementById('root')
72
+ );
73
+ };
51
74
 
52
- const benchmark = await runBenchmark('CS', [
53
- {
54
- name: 'CS (1 array element)',
55
- fn: () => {
56
- renderToString(
57
- <CC>
58
- <CS nonce={nonce}>{[stylesStr]}</CS>
59
- <span className={className} style={style}>
60
- hello world
61
- </span>
62
- </CC>
63
- );
75
+ const tests = [
76
+ {
77
+ name: 'CS (1 array element)',
78
+ fn: () => {
79
+ renderJSX((key) => (
80
+ <CC key={`cs1-${key}`}>
81
+ <CS nonce={nonce}>{[stylesStr]}</CS>
82
+ <div className={className} />
83
+ </CC>
84
+ ));
85
+ },
64
86
  },
65
- },
66
- {
67
- name: 'CS (n array elements)',
68
- fn: () => {
69
- renderToString(
70
- <CC>
71
- <CS nonce={nonce}>{stylesArr}</CS>
72
- <span className={className} style={style}>
73
- hello world
74
- </span>
75
- </CC>
76
- );
87
+ {
88
+ name: 'CS (n array elements)',
89
+ fn: () => {
90
+ renderJSX((key) => (
91
+ <CC key={`csn-${key}`}>
92
+ <CS nonce={nonce}>{stylesArr}</CS>
93
+ <div className={className} />
94
+ </CC>
95
+ ));
96
+ },
77
97
  },
78
- },
79
- {
80
- name: 'StyleArr',
81
- fn: () => {
82
- renderToString(
83
- <CC>
84
- <StyleArr nonce={nonce}>{stylesArr}</StyleArr>
85
- <span className={className} style={style}>
86
- hello world
87
- </span>
88
- </CC>
89
- );
98
+ {
99
+ name: 'MemoCS (1 array element)',
100
+ fn: () => {
101
+ renderJSX((key) => (
102
+ <CC key={`memo-cs1-${key}`}>
103
+ <MemoCS nonce={nonce}>{[stylesStr]}</MemoCS>
104
+ <div className={className} />
105
+ </CC>
106
+ ));
107
+ },
90
108
  },
91
- },
92
- {
93
- name: 'StyleStr',
94
- fn: () => {
95
- renderToString(
96
- <CC>
97
- <StyleStr nonce={nonce}>{stylesStr}</StyleStr>
98
- <span className={className} style={style}>
99
- hello world
100
- </span>
101
- </CC>
102
- );
109
+ {
110
+ name: 'MemoCS (n array elements)',
111
+ fn: () => {
112
+ renderJSX((key) => (
113
+ <CC key={`memo-csn-${key}`}>
114
+ <MemoCS nonce={nonce}>{stylesArr}</MemoCS>
115
+ <div className={className} />
116
+ </CC>
117
+ ));
118
+ },
103
119
  },
104
- },
105
- ]);
120
+ ...(env === 'server'
121
+ ? [
122
+ {
123
+ name: 'StyleBucketFromArray',
124
+ fn: () => {
125
+ renderJSX((key) => (
126
+ <CC key={`sbfa-${key}`}>
127
+ <StyleBucketFromArray nonce={nonce}>{stylesArr}</StyleBucketFromArray>
128
+ <div className={className} />
129
+ </CC>
130
+ ));
131
+ },
132
+ },
133
+ {
134
+ name: 'StyleBucketFromString',
135
+ fn: () => {
136
+ renderJSX((key) => (
137
+ <CC key={`sbfs-${key}`}>
138
+ <StyleBucketFromString nonce={nonce}>{stylesStr}</StyleBucketFromString>
139
+ <div className={className} />
140
+ </CC>
141
+ ));
142
+ },
143
+ },
144
+ ]
145
+ : []),
146
+ ];
106
147
 
107
- expect(benchmark).toMatchObject({
108
- fastest: expect.not.arrayContaining(['StyleStr', 'CS (n array elements)']),
109
- });
110
- }, 30000);
148
+ const benchmark = await runBenchmark('CS', tests);
149
+
150
+ const slowest = tests.map((t) => t.name).filter((n) => !fastest.includes(n));
151
+ for (const name of slowest) {
152
+ expect(benchmark.fastest).not.toContain(name);
153
+ }
154
+ }, 60000);
155
+ });
111
156
  });
@@ -2,20 +2,17 @@ import React, { createContext, useContext } from 'react';
2
2
 
3
3
  const Cache = createContext<Record<string, true> | null>(null);
4
4
 
5
- export const useCache = (): Record<string, true> => {
6
- return useContext(Cache) || {};
7
- };
8
-
9
- export type StyleStrProps = {
10
- children: string;
5
+ export type StyleBucketFromArrayProps = {
6
+ children: string[];
11
7
  nonce: string;
12
8
  };
13
9
 
14
- export function StyleStr({ children, nonce }: StyleStrProps): JSX.Element | null {
15
- const inserted = useCache();
10
+ export function StyleBucketFromArray({
11
+ children: sheets,
12
+ nonce,
13
+ }: StyleBucketFromArrayProps): JSX.Element | null {
14
+ const inserted = useContext(Cache) || {};
16
15
 
17
- // The following code will not exist in the browser bundle.
18
- const sheets = children.split('.');
19
16
  let toInsert = '';
20
17
 
21
18
  for (let i = 0; i < sheets.length; i++) {
@@ -33,15 +30,18 @@ export function StyleStr({ children, nonce }: StyleStrProps): JSX.Element | null
33
30
  return <style nonce={nonce}>{toInsert}</style>;
34
31
  }
35
32
 
36
- export type StyleArrProps = {
37
- children: string[];
33
+ export type StyleBucketFromStringProps = {
34
+ children: string;
38
35
  nonce: string;
39
36
  };
40
37
 
41
- export function StyleArr({ children: sheets, nonce }: StyleArrProps): JSX.Element | null {
42
- const inserted = useCache();
38
+ export function StyleBucketFromString({
39
+ children,
40
+ nonce,
41
+ }: StyleBucketFromStringProps): JSX.Element | null {
42
+ const inserted = useContext(Cache) || {};
43
43
 
44
- // The following code will not exist in the browser bundle.
44
+ const sheets = children.split('.');
45
45
  let toInsert = '';
46
46
 
47
47
  for (let i = 0; i < sheets.length; i++) {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @jest-environment node
3
+ */
4
+
1
5
  import React from 'react';
2
6
  import { renderToStaticMarkup, renderToString } from 'react-dom/server';
3
7
 
@@ -2,10 +2,6 @@ import { render } from '@testing-library/react';
2
2
  import React from 'react';
3
3
  import type { ComponentType } from 'react';
4
4
 
5
- jest.mock('../is-node', () => ({
6
- isNodeEnvironment: () => false,
7
- }));
8
-
9
5
  describe('<Style />', () => {
10
6
  let consoleErrorSpy: jest.SpyInstance;
11
7
 
File without changes
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Flowtype definitions for cache
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.15.0
5
+ * @flow
6
+ */
7
+ /**
8
+ * Returns `true` when caching should be disabled, else `false`.
9
+ *
10
+ * Any code within this check will be removed in the output bundles:
11
+ *
12
+ * ```js
13
+ * if (isCacheDisabled()) {
14
+ * // This code will be removed from the output bundles
15
+ * }
16
+ * ```
17
+ */
18
+ declare export var isCacheDisabled: () => boolean;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Returns `true` when caching should be disabled, else `false`.
3
+ *
4
+ * Any code within this check will be removed in the output bundles:
5
+ *
6
+ * ```js
7
+ * if (isCacheDisabled()) {
8
+ * // This code will be removed from the output bundles
9
+ * }
10
+ * ```
11
+ */
12
+ export const isCacheDisabled = (): boolean => {
13
+ return process.env.NODE_ENV === 'test' && process.env.CACHE === 'false';
14
+ };
File without changes
@@ -11,6 +11,5 @@
11
11
  * ```
12
12
  */
13
13
  export const isNodeEnvironment = (): boolean => {
14
- // https://nodejs.org/api/process.html#process_process_release
15
- return typeof process !== 'undefined' && process?.release?.name === 'node';
14
+ return typeof window === 'undefined';
16
15
  };
@@ -1,3 +1,4 @@
1
+ import { isCacheDisabled } from './cache';
1
2
  import type { Bucket, StyleSheetOpts } from './types';
2
3
 
3
4
  /**
@@ -77,8 +78,13 @@ function lazyAddStyleBucketToHead(bucketName: Bucket, opts: StyleSheetOpts): HTM
77
78
  const tag = document.createElement('style');
78
79
  opts.nonce && tag.setAttribute('nonce', opts.nonce);
79
80
  tag.appendChild(document.createTextNode(''));
80
- styleBucketsInHead[bucketName] = tag;
81
81
  document.head.insertBefore(tag, nextBucketFromCache);
82
+
83
+ if (isCacheDisabled()) {
84
+ return tag;
85
+ }
86
+
87
+ styleBucketsInHead[bucketName] = tag;
82
88
  }
83
89
 
84
90
  return styleBucketsInHead[bucketName]!;
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { createContext, useContext } from 'react';
3
3
 
4
+ import { isCacheDisabled } from './cache';
4
5
  import { isNodeEnvironment } from './is-node';
5
6
  import type { ProviderComponent, UseCacheHook } from './types';
6
7
 
@@ -27,6 +28,10 @@ if (!isNodeEnvironment()) {
27
28
  * Hook using the cache created on the server or client.
28
29
  */
29
30
  export const useCache: UseCacheHook = () => {
31
+ if (isCacheDisabled()) {
32
+ return {};
33
+ }
34
+
30
35
  if (isNodeEnvironment()) {
31
36
  // On the server we use React Context to we don't leak the cache between SSR calls.
32
37
  // During runtime this hook isn't conditionally called - it is at build time that the flow gets decided.
File without changes
File without changes
@@ -1,4 +1,5 @@
1
1
  /** @jsxImportSource @compiled/react */
2
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
3
  import { styled } from '@compiled/react';
3
4
  import { render } from '@testing-library/react';
4
5
 
File without changes
File without changes
File without changes