Skip to content
This repository was archived by the owner on Nov 11, 2024. It is now read-only.

Commit 5302cda

Browse files
committed
feat: usage of ESM imports instead of CJS
BREAKING CHANGE: Require Node.js >= 12 close #27
1 parent 39a6a20 commit 5302cda

File tree

4 files changed

+61
-34
lines changed

4 files changed

+61
-34
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const stripIndent = require('strip-indent')
2-
const sass = require('sass')
1+
import stripIndent from 'strip-indent'
2+
import sass from 'sass'
33

4-
module.exports = (css, settings) => {
4+
export default (css, settings) => {
55
const cssWithPlaceholders = css
66
.replace(
77
/%%styled-jsx-placeholder-(\d+)%%%(\w*\s*[),;!{])/g,

package-lock.json

Lines changed: 50 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "3.0.0",
44
"description": "Plugin to add Sass support to styled-jsx",
55
"license": "MIT",
6+
"type": "module",
67
"main": "index.js",
78
"engines": {
89
"node": ">=12.0.0"
@@ -65,7 +66,7 @@
6566
"postpublish": "pinst --enable"
6667
},
6768
"dependencies": {
68-
"strip-indent": "3.0.0"
69+
"strip-indent": "4.0.0"
6970
},
7071
"devDependencies": {
7172
"@commitlint/cli": "12.1.4",

test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const assert = require('assert')
2-
const path = require('path')
3-
const fs = require('fs')
4-
const stripIndent = require('strip-indent')
5-
const plugin = require('./')
1+
import assert from 'node:assert'
2+
import fs from 'node:fs'
3+
4+
import stripIndent from 'strip-indent'
5+
import plugin from './index.js'
66

77
const cleanup = (str) => stripIndent(str).trim()
88

@@ -143,7 +143,7 @@ describe('styled-jsx-plugin-sass', () => {
143143

144144
it('works with relative @import', () => {
145145
const filename = 'fixtures/entry.scss'
146-
const file = fs.readFileSync(path.join(__dirname, filename))
146+
const file = fs.readFileSync(filename)
147147

148148
assert.strictEqual(
149149
plugin(file.toString(), { babel: { filename } }).trim(),

0 commit comments

Comments
 (0)