diff --git a/lib/json-to-sass.js b/lib/json-to-sass.js index 75c5720..da2c3e7 100644 --- a/lib/json-to-sass.js +++ b/lib/json-to-sass.js @@ -1,5 +1,11 @@ import sass from 'sass'; -import { isArray, isPlainObject, isString, isNumber, isBoolean } from 'lodash'; +import { + isArray, + isPlainObject, + isString, + isNumber, + isBoolean +} from 'lodash-es'; import parseColor from 'parse-color'; import parseUnit from 'parse-css-dimension'; diff --git a/lib/sass-to-json.js b/lib/sass-to-json.js index 10abb83..e20b0a1 100644 --- a/lib/sass-to-json.js +++ b/lib/sass-to-json.js @@ -1,5 +1,5 @@ import sass from 'sass'; -import { round } from 'lodash'; +import { round } from 'lodash-es'; import rgbHex from 'rgb-hex'; import shortHexColor from 'shorten-css-hex'; diff --git a/package.json b/package.json index c50233c..6433027 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "version": "version-changelog CHANGELOG.md && changelog-verify CHANGELOG.md && git add CHANGELOG.md" }, "dependencies": { - "lodash": "^4.17.20", + "lodash-es": "^4.17.20", "parse-color": "^1.0.0", "parse-css-dimension": "^1.1.0", "rgb-hex": "^3.0.0", @@ -46,6 +46,8 @@ "sass": ">=1" }, "devDependencies": { + "@rollup/plugin-commonjs": "^17.0.0", + "@rollup/plugin-node-resolve": "^11.0.1", "changelog-verify": "^1.1.2", "eslint": "^7.11.0", "eslint-config-niksy": "^9.0.0", diff --git a/rollup.config.js b/rollup.config.js index 7148d31..8010873 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -2,48 +2,50 @@ const path = require('path'); const { promises: fs } = require('fs'); +const { default: resolve } = require('@rollup/plugin-node-resolve'); +const commonjs = require('@rollup/plugin-commonjs'); -module.exports = { - input: 'index.js', - output: [ - { +const packageType = (() => { + return { + name: 'package-type', + async writeBundle(output) { + let prefix, type; + if (output.file.includes('cjs/')) { + prefix = 'cjs'; + type = 'commonjs'; + } else if (output.file.includes('esm/')) { + prefix = 'esm'; + type = 'module'; + } + if (typeof prefix !== 'undefined') { + const package_ = path.join(prefix, 'package.json'); + try { + await fs.unlink(package_); + } catch (error) {} + await fs.writeFile(package_, JSON.stringify({ type }), 'utf8'); + } + } + }; +})(); + +module.exports = [ + { + input: 'index.js', + output: { file: 'cjs/index.js', format: 'cjs', exports: 'auto', sourcemap: true }, - { + plugins: [packageType, resolve({ resolveOnly: ['lodash-es'] })] + }, + { + input: 'index.js', + output: { file: 'esm/index.js', format: 'esm', sourcemap: true - } - ], - plugins: [ - (() => { - return { - name: 'package-type', - async writeBundle(output) { - let prefix, type; - if (output.file.includes('cjs/')) { - prefix = 'cjs'; - type = 'commonjs'; - } else if (output.file.includes('esm/')) { - prefix = 'esm'; - type = 'module'; - } - if (typeof prefix !== 'undefined') { - const package_ = path.join(prefix, 'package.json'); - try { - await fs.unlink(package_); - } catch (error) {} - await fs.writeFile( - package_, - JSON.stringify({ type }), - 'utf8' - ); - } - } - }; - })() - ] -}; + }, + plugins: [packageType] + } +];