@stylexjs/rollup-plugin 0.3.0 → 0.4.1

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.
package/.babelrc.cjs ADDED
@@ -0,0 +1,17 @@
1
+ module.exports = {
2
+ assumptions: {
3
+ iterableIsArray: true,
4
+ },
5
+ presets: [
6
+ [
7
+ '@babel/preset-env',
8
+ {
9
+ exclude: ['@babel/plugin-transform-typeof-symbol'],
10
+ targets: 'defaults',
11
+ modules: process.env.NODE_ENV === 'test' ? 'commonjs' : false,
12
+ },
13
+ ],
14
+ '@babel/preset-flow',
15
+ ],
16
+ plugins: [['babel-plugin-syntax-hermes-parser', { flow: 'detect' }]],
17
+ };
package/README.md CHANGED
@@ -1,3 +1,33 @@
1
1
  # @stylexjs/rollup-plugin
2
2
 
3
- ...
3
+ ## Documentation Website
4
+ [https://stylexjs.com](https://stylexjs.com)
5
+
6
+ ## Installation
7
+
8
+ Install the package by using:
9
+ ```bash
10
+ npm install --save-dev @stylexjs/rollup-plugin
11
+ ```
12
+
13
+ or with yarn:
14
+
15
+ ```
16
+ yarn add --dev @stylexjs/rollup-plugin
17
+ ```
18
+
19
+ Add the following to you `rollup.config.mjs`
20
+ ```javascript
21
+ import stylexPlugin from '@stylexjs/rollup-plugin';
22
+
23
+ const config = {
24
+ input: './index.js',
25
+ output: {
26
+ file: './.build/bundle.js',
27
+ format: 'es',
28
+ },
29
+ plugins: [stylexPlugin({ fileName: 'stylex.css' })],
30
+ };
31
+
32
+ export default config;
33
+ ```
@@ -9,19 +9,23 @@
9
9
 
10
10
  'use strict';
11
11
 
12
- const path = require('path');
13
- const rollup = require('rollup');
14
- const { babel } = require('@rollup/plugin-babel');
15
- const commonjs = require('@rollup/plugin-commonjs');
16
- const { nodeResolve } = require('@rollup/plugin-node-resolve');
17
- const stylexPlugin = require('../src/index');
12
+ import path from 'path';
13
+ import rollup from 'rollup';
14
+ import { babel } from '@rollup/plugin-babel';
15
+ import commonjs from '@rollup/plugin-commonjs';
16
+ import { nodeResolve } from '@rollup/plugin-node-resolve';
17
+ import stylexPlugin from '../src/index';
18
18
 
19
19
  describe('rollup-plugin-stylex', () => {
20
20
  async function runStylex(options) {
21
21
  // Configure a rollup bundle
22
22
  const bundle = await rollup.rollup({
23
23
  // Remove stylex runtime from bundle
24
- external: ['stylex'],
24
+ external: [
25
+ 'stylex',
26
+ '@stylexjs/stylex',
27
+ '@stylexjs/stylex/lib/stylex-inject',
28
+ ],
25
29
  input: path.resolve(__dirname, '__fixtures__/index.js'),
26
30
  plugins: [
27
31
  nodeResolve(),
@@ -31,7 +35,7 @@ describe('rollup-plugin-stylex', () => {
31
35
  configFile: path.resolve(__dirname, '__fixtures__/.babelrc.json'),
32
36
  exclude: [/npmStyles\.js/],
33
37
  }),
34
- stylexPlugin(options),
38
+ stylexPlugin({ useCSSLayers: true, ...options }),
35
39
  ],
36
40
  });
37
41
 
@@ -169,7 +173,8 @@ describe('rollup-plugin-stylex', () => {
169
173
  expect(css).toBeUndefined();
170
174
 
171
175
  expect(js).toMatchInlineSnapshot(`
172
- "import stylex from 'stylex';
176
+ "import _inject from '@stylexjs/stylex/lib/stylex-inject';
177
+ import stylex from 'stylex';
173
178
 
174
179
  /**
175
180
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -180,8 +185,8 @@ describe('rollup-plugin-stylex', () => {
180
185
  *
181
186
  */
182
187
 
183
- stylex.inject(".x1lliihq{display:block}", 3000);
184
- stylex.inject(".xh8yej3{width:100%}", 4000);
188
+ _inject(".x1lliihq{display:block}", 3000);
189
+ _inject(".xh8yej3{width:100%}", 4000);
185
190
  var styles$2 = {
186
191
  bar: {
187
192
  "otherStyles__styles.bar": "otherStyles__styles.bar",
@@ -200,9 +205,9 @@ describe('rollup-plugin-stylex', () => {
200
205
  *
201
206
  */
202
207
 
203
- stylex.inject(".xt0psk2{display:inline}", 3000);
204
- stylex.inject(".x1egiwwb{height:500px}", 4000);
205
- stylex.inject(".x3hqpx7{width:50%}", 4000);
208
+ _inject(".xt0psk2{display:inline}", 3000);
209
+ _inject(".x1egiwwb{height:500px}", 4000);
210
+ _inject(".x3hqpx7{width:50%}", 4000);
206
211
  const styles$1 = {
207
212
  baz: {
208
213
  "npmStyles__styles.baz": "npmStyles__styles.baz",
@@ -222,13 +227,13 @@ describe('rollup-plugin-stylex', () => {
222
227
  *
223
228
  */
224
229
 
225
- stylex.inject("@keyframes xgnty7z-B{0%{opacity:.25;}100%{opacity:1;}}", 1);
226
- stylex.inject(".xeuoslp{animation-name:xgnty7z-B}", 3000);
227
- stylex.inject(".x78zum5{display:flex}", 3000);
228
- stylex.inject(".x1hm9lzh{margin-inline-start:10px}", 3000);
229
- stylex.inject(".xlrshdv{margin-top:99px}", 4000);
230
- stylex.inject(".x1egiwwb{height:500px}", 4000);
231
- stylex.inject(".x1oz5o6v:hover{background:red}", 1130);
230
+ _inject("@keyframes xgnty7z-B{0%{opacity:.25;}100%{opacity:1;}}", 1);
231
+ _inject(".xeuoslp{animation-name:xgnty7z-B}", 3000);
232
+ _inject(".x78zum5{display:flex}", 3000);
233
+ _inject(".x1hm9lzh{margin-inline-start:10px}", 3000);
234
+ _inject(".xlrshdv{margin-top:99px}", 4000);
235
+ _inject(".x1egiwwb{height:500px}", 4000);
236
+ _inject(".x1oz5o6v:hover{background:red}", 1130);
232
237
  var styles = {
233
238
  foo: {
234
239
  "index__styles.foo": "index__styles.foo",