Skip to content

Commit d9012a8

Browse files
author
Sam Goody
committed
Moved from CJS to ESM
That is where the puck is going.
1 parent 68adf31 commit d9012a8

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"version": "0.0.1",
44
"description": "Tailwind plugin which enables setting CSS rules for all children in parent",
55
"main": "index.js",
6+
"type": "module",
67
"scripts": {
7-
"test": "jest"
8+
"test": "node --experimental-vm-modules ./node_modules/.bin/jest"
89
},
910
"repository": {
1011
"type": "git",
@@ -29,4 +30,4 @@
2930
"postcss": "^8.4.6",
3031
"tailwindcss": "^3.0.18"
3132
}
32-
}
33+
}

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const plugin = require('tailwindcss/plugin');
1+
import { default as plugin } from 'tailwindcss/plugin'
22

33
const aliases = ['children', 'child'];
44

55
let variants = [
66
...aliases.map(v => [v, '& > *'])
77
]
88

9-
module.exports = plugin(({ addVariant }) =>
9+
export default plugin(({ addVariant }) =>
1010
variants.forEach(v => addVariant.apply(null, v)));

tests/test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
const fs = require('fs');
2-
const path = require('path');
3-
const postcss = require('postcss');
4-
const tailwind = require('tailwindcss');
5-
const children = require('../src/index.js');
1+
import { readFileSync } from 'fs';
2+
import { resolve } from 'path';
3+
import postcss from 'postcss';
4+
import tailwind from 'tailwindcss';
5+
import children from '../src/index.js';
66

7-
const cssMatch = require('jest-matcher-css')
7+
import cssMatch from 'jest-matcher-css';
88
expect.extend({ cssMatch })
99

1010
test('variants', async () => {
1111

1212
let config = {
13-
content: [path.resolve(__dirname, './test.html')],
1413
plugins: [children],
14+
content: [resolve('./tests/test.html')],
1515
}
1616

1717
let input = '@tailwind utilities'
1818

1919
let result = await postcss(tailwind(config)).process(input, {from: undefined})
2020

2121
// console.log(result.css, 'result.css')
22-
let expected = fs.readFileSync(path.resolve(__dirname, './test.css'), 'utf8')
22+
let expected = readFileSync(resolve('./tests/test.css'), 'utf8')
2323
expect(result.css).cssMatch(expected)
2424
})

0 commit comments

Comments
 (0)