Skip to content

Commit

Permalink
feat: usage of ESM imports instead of CJS
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Require Node.js >= 12

close #27
  • Loading branch information
theoludwig committed Jul 23, 2021
1 parent 39a6a20 commit 5302cda
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 34 deletions.
6 changes: 3 additions & 3 deletions index.js
@@ -1,7 +1,7 @@
const stripIndent = require('strip-indent')
const sass = require('sass')
import stripIndent from 'strip-indent'
import sass from 'sass'

module.exports = (css, settings) => {
export default (css, settings) => {
const cssWithPlaceholders = css
.replace(
/%%styled-jsx-placeholder-(\d+)%%%(\w*\s*[),;!{])/g,
Expand Down
74 changes: 50 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -3,6 +3,7 @@
"version": "3.0.0",
"description": "Plugin to add Sass support to styled-jsx",
"license": "MIT",
"type": "module",
"main": "index.js",
"engines": {
"node": ">=12.0.0"
Expand Down Expand Up @@ -65,7 +66,7 @@
"postpublish": "pinst --enable"
},
"dependencies": {
"strip-indent": "3.0.0"
"strip-indent": "4.0.0"
},
"devDependencies": {
"@commitlint/cli": "12.1.4",
Expand Down
12 changes: 6 additions & 6 deletions test.js
@@ -1,8 +1,8 @@
const assert = require('assert')
const path = require('path')
const fs = require('fs')
const stripIndent = require('strip-indent')
const plugin = require('./')
import assert from 'node:assert'
import fs from 'node:fs'

import stripIndent from 'strip-indent'
import plugin from './index.js'

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

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

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

assert.strictEqual(
plugin(file.toString(), { babel: { filename } }).trim(),
Expand Down

0 comments on commit 5302cda

Please sign in to comment.