From dc21cdbed616e0423fb14efbabf6b785936a1380 Mon Sep 17 00:00:00 2001 From: Ely De La Cruz <603428+elycruz@users.noreply.github.com> Date: Sat, 17 Sep 2022 09:26:50 -0400 Subject: [PATCH 1/3] Added .npmrc and .node-version files. - Updated .npmignore, and own email in package.json. --- .node-version | 1 + .npmignore | 2 ++ .npmrc | 1 + package.json | 2 +- 4 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .node-version create mode 100644 .npmrc diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..0cee939 --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +18 diff --git a/.npmignore b/.npmignore index 65a909d..02850a7 100644 --- a/.npmignore +++ b/.npmignore @@ -5,6 +5,8 @@ .editorconfig .gitignore +.node-version +.npmrc CHANGELOG* CODEOWNERS* diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..35c8df1 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +version=18 diff --git a/package.json b/package.json index de265d2..784a3b1 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ ], "author": "BinRui.Guan ", "maintainers": [ - "elycruz (https://github.com/elycruz)" + "elycruz (https://github.com/elycruz)" ], "license": "MIT", "bugs": { From 17031fbd708bc23083628e4dad2f352339bed1df Mon Sep 17 00:00:00 2001 From: Ely De La Cruz <603428+elycruz@users.noreply.github.com> Date: Sat, 17 Sep 2022 13:47:02 -0400 Subject: [PATCH 2/3] issue-#72 - Fixed bug where generated css was being duplicated in compiled css output. - Added test/example showing how to extract sass variables to generated output *.js module files. - Simplified 'License' section in main README. - Updated 'LICENSE' to point to './humans.txt' for maintaners/owners list. --- LICENSE | 2 +- README.md | 8 +- MAINTAINERS => humans.txt | 5 +- package-lock.json | 87 ++++++++++++++++++- package.json | 2 + src/index.ts | 5 +- test/assets/actual_a--with-icss-exports.scss | 12 +++ test/assets/expect_a--with-icss-exports.css | 1 + .../processor-promise/with-icss-exports.js | 6 ++ test/index.test.ts | 46 ++++++++-- 10 files changed, 151 insertions(+), 23 deletions(-) rename MAINTAINERS => humans.txt (81%) create mode 100644 test/assets/actual_a--with-icss-exports.scss create mode 100644 test/assets/expect_a--with-icss-exports.css create mode 100644 test/fixtures/processor-promise/with-icss-exports.js diff --git a/LICENSE b/LICENSE index 2c4f2c4..66b6e05 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 rollup-plugin-sass maintainers (see './MAINTAINERS' file) +Copyright (c) 2016 rollup-plugin-sass maintainers (see './humans.txt') Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/README.md b/README.md index 243110c..aaee89c 100644 --- a/README.md +++ b/README.md @@ -155,11 +155,7 @@ sass({ }) ``` -## Maintainers - -- [ElyCruz](https://github.com/elycruz) - ## License -[MIT](./LICENSE) © 2022 [elycruz](https://github.com/elycruz), -© 2016 [BinRui.Guan](mailto:differui@gmail.com) +[MIT](./LICENSE) [elycruz](https://github.com/elycruz), +[BinRui.Guan](mailto:differui@gmail.com) diff --git a/MAINTAINERS b/humans.txt similarity index 81% rename from MAINTAINERS rename to humans.txt index 4633d31..14daa02 100644 --- a/MAINTAINERS +++ b/humans.txt @@ -1,8 +1,5 @@ -# Maintainers +# Maintainers/Authors 2022 Ely De La Cruz (https://github.com/elycruz) - -# Legacy - 2016 BinRui.Guan - Author 2016 Thomas Ghysels (https://github.com/thgh) diff --git a/package-lock.json b/package-lock.json index b3d6b4e..7ac5826 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "@rollup/pluginutils": "^3.1.0", + "icss-utils": "^5.1.0", "resolve": "^1.5.0", "sass": "^1.7.2" }, @@ -25,6 +26,7 @@ "eslint": "^7.32.0", "jsdom": "^17.0.0", "nyc": "^15.1.0", + "postcss": "^8.4.16", "rollup": "^1.32.1", "sinon": "^7.2.2", "ts-node": "^10.9.1", @@ -3016,6 +3018,17 @@ "node": ">=0.10.0" } }, + "node_modules/icss-utils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", + "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==", + "engines": { + "node": "^10 || ^12 || >= 14" + }, + "peerDependencies": { + "postcss": "^8.1.0" + } + }, "node_modules/ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", @@ -3821,6 +3834,17 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "node_modules/nanoid": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -4365,8 +4389,7 @@ "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" }, "node_modules/picomatch": { "version": "2.3.0", @@ -4492,6 +4515,29 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/postcss": { + "version": "8.4.16", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz", + "integrity": "sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + } + ], + "dependencies": { + "nanoid": "^3.3.4", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -5037,6 +5083,14 @@ "node": ">=0.10.0" } }, + "node_modules/source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/spawn-wrap": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-2.0.0.tgz", @@ -8110,6 +8164,12 @@ "safer-buffer": ">= 2.1.2 < 3" } }, + "icss-utils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", + "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==", + "requires": {} + }, "ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", @@ -8719,6 +8779,11 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "nanoid": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==" + }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -9136,8 +9201,7 @@ "picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" }, "picomatch": { "version": "2.3.0", @@ -9217,6 +9281,16 @@ "irregular-plurals": "^3.3.0" } }, + "postcss": { + "version": "8.4.16", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz", + "integrity": "sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ==", + "requires": { + "nanoid": "^3.3.4", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + } + }, "prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -9600,6 +9674,11 @@ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, + "source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==" + }, "spawn-wrap": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-2.0.0.tgz", diff --git a/package.json b/package.json index 784a3b1..9e6059d 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ }, "dependencies": { "@rollup/pluginutils": "^3.1.0", + "icss-utils": "^5.1.0", "resolve": "^1.5.0", "sass": "^1.7.2" }, @@ -72,6 +73,7 @@ "eslint": "^7.32.0", "jsdom": "^17.0.0", "nyc": "^15.1.0", + "postcss": "^8.4.16", "rollup": "^1.32.1", "sinon": "^7.2.2", "ts-node": "^10.9.1", diff --git a/src/index.ts b/src/index.ts index a77089d..3095179 100644 --- a/src/index.ts +++ b/src/index.ts @@ -88,10 +88,9 @@ const MATCH_SASS_FILENAME_RE = /\.sass$/, 'See https://github.com/differui/rollup-plugin-sass#processor'); } const outCss = result.css; + delete result.css; const restExports = Object.keys(result).reduce((agg, name) => - name === 'css' ? agg : agg + `export const ${name} = ${JSON.stringify(result[name])};\n` - , '' - ); + agg + `export const ${name} = ${JSON.stringify(result[name])};\n`, ''); return [outCss, restExports]; }) .then(([resolvedCss, restExports]) => { diff --git a/test/assets/actual_a--with-icss-exports.scss b/test/assets/actual_a--with-icss-exports.scss new file mode 100644 index 0000000..467dcf3 --- /dev/null +++ b/test/assets/actual_a--with-icss-exports.scss @@ -0,0 +1,12 @@ +$color_red: red; +$color_blue: blue; + +body { + color: $color_red; + background: $color_blue; +} + +:export { + color: $color_red; + color2: $color_blue; +} diff --git a/test/assets/expect_a--with-icss-exports.css b/test/assets/expect_a--with-icss-exports.css new file mode 100644 index 0000000..b491714 --- /dev/null +++ b/test/assets/expect_a--with-icss-exports.css @@ -0,0 +1 @@ +body{color:red;background:blue;} diff --git a/test/fixtures/processor-promise/with-icss-exports.js b/test/fixtures/processor-promise/with-icss-exports.js new file mode 100644 index 0000000..2cf74a5 --- /dev/null +++ b/test/fixtures/processor-promise/with-icss-exports.js @@ -0,0 +1,6 @@ +import actualA2, {color, color2} from '../../assets/actual_a--with-icss-exports.scss'; +import actualB from '../../assets/actual_b.scss'; + +export {color, color2}; + +export default actualA2 + actualB; diff --git a/test/index.test.ts b/test/index.test.ts index 52999dc..7bca199 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -7,6 +7,8 @@ import * as sassJs from 'sass'; import sass from '../src/index'; import {SassOptions} from "../src/types"; import {error} from "../src/utils"; +import postcss from "postcss"; +import {extractICSS} from "icss-utils"; const repoRoot = path.join(__dirname, '../'), @@ -39,7 +41,7 @@ const repoRoot = path.join(__dirname, '../'), unwrap = output => output[0].code; -let expectA, expectB, expectC, expectD, expectE; +let expectA, expectA2, expectB, expectC, expectD, expectE; test.before(async () => { const mkDir = () => fs.mkdir(tmpDir); @@ -48,6 +50,7 @@ test.before(async () => { .then(mkDir, mkDir) .then(() => Promise.all([ 'test/assets/expect_a.css', + 'test/assets/expect_a--with-icss-exports.css', 'test/assets/expect_b.css', 'test/assets/expect_c.css', 'test/assets/expect_d.css', @@ -55,8 +58,9 @@ test.before(async () => { ] .map(xs => fs.readFile(xs).then(buff => buff.toString())) )) - .then(([a, b, c, d, e]) => { + .then(([a, a2, b, c, d, e]) => { expectA = squash(a); + expectA2 = squash(a2); expectB = squash(b); expectC = squash(c); expectD = squash(d); @@ -266,7 +270,7 @@ test('should processor return as object', async t => { t.true(squash(unwrap(output)).indexOf('bar') > -1); }); -test('should processor return as promise', async t => { +test('should support processor return type `Promise`', async t => { const outputBundle = await rollup({ input: 'test/fixtures/processor-promise/index.js', plugins: [ @@ -283,6 +287,38 @@ test('should processor return as promise', async t => { t.true(squash(unwrap(output)).indexOf(expectB) > -1); }); +test('should support processor return type `Promise<{css: string, icssExport: {}, icssImport: {}}}>', async t => { + const outputBundle = await rollup({ + input: 'test/fixtures/processor-promise/with-icss-exports.js', + plugins: [ + sass({ + processor: (css) => new Promise((resolve, reject) => { + const pcssRootNodeRslt = postcss.parse(css), + extractedIcss = extractICSS(pcssRootNodeRslt, true), + cleanedCss = pcssRootNodeRslt.toString(), + out = Object.assign({}, extractedIcss.icssExports, { + css: cleanedCss, + }); + console.table(extractedIcss); + console.log(out); + resolve(out); + }), + options: sassOptions, + }), + ], + }), + {output} = await outputBundle.generate(generateOptions); + + outputBundle.write({ + ...generateOptions, + file: path.join(tmpDir, 'with--icss-exports.js'), + }); + // console.log('output:', output); + + t.true(squash(unwrap(output)).includes(expectA2)); + t.true(squash(unwrap(output)).includes(expectB)); +}); + test('should processor throw error', async t => { await t.throwsAsync(async () => rollup({ input: 'test/fixtures/processor-error/index.js', @@ -446,6 +482,6 @@ test('When `sourcemap` is set, to `true`, adjacent source map file should be out }); test.after(async (): Promise => { - return fs.rmdir(tmpDir, {recursive: true}) - .catch(error); + // return fs.rmdir(tmpDir, {recursive: true}) + // .catch(error); }); From 07aef77539b8ea706a7e3c32cdb7e6ea1822dce1 Mon Sep 17 00:00:00 2001 From: Ely De La Cruz <603428+elycruz@users.noreply.github.com> Date: Sat, 17 Sep 2022 14:02:05 -0400 Subject: [PATCH 3/3] issue-#72 - Cleaned up sass variables extraction test/example. - Updated package version. --- package-lock.json | 24 +++++++++++++++------ package.json | 4 ++-- test/assets/expect_a--with-icss-exports.css | 2 +- test/index.test.ts | 21 +++++++----------- 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7ac5826..7ebfd41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,15 @@ { "name": "rollup-plugin-sass", - "version": "1.2.13", + "version": "1.2.14", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "rollup-plugin-sass", - "version": "1.2.13", + "version": "1.2.14", "license": "MIT", "dependencies": { "@rollup/pluginutils": "^3.1.0", - "icss-utils": "^5.1.0", "resolve": "^1.5.0", "sass": "^1.7.2" }, @@ -24,6 +23,7 @@ "coveralls": "^3.1.1", "downlevel-dts": "^0.10.0", "eslint": "^7.32.0", + "icss-utils": "^5.1.0", "jsdom": "^17.0.0", "nyc": "^15.1.0", "postcss": "^8.4.16", @@ -3022,6 +3022,7 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==", + "dev": true, "engines": { "node": "^10 || ^12 || >= 14" }, @@ -3838,6 +3839,7 @@ "version": "3.3.4", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", + "dev": true, "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -4389,7 +4391,8 @@ "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true }, "node_modules/picomatch": { "version": "2.3.0", @@ -4519,6 +4522,7 @@ "version": "8.4.16", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz", "integrity": "sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ==", + "dev": true, "funding": [ { "type": "opencollective", @@ -5087,6 +5091,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -8168,6 +8173,7 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==", + "dev": true, "requires": {} }, "ignore": { @@ -8782,7 +8788,8 @@ "nanoid": { "version": "3.3.4", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", - "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==" + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", + "dev": true }, "natural-compare": { "version": "1.4.0", @@ -9201,7 +9208,8 @@ "picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true }, "picomatch": { "version": "2.3.0", @@ -9285,6 +9293,7 @@ "version": "8.4.16", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz", "integrity": "sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ==", + "dev": true, "requires": { "nanoid": "^3.3.4", "picocolors": "^1.0.0", @@ -9677,7 +9686,8 @@ "source-map-js": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", - "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==" + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "dev": true }, "spawn-wrap": { "version": "2.0.0", diff --git a/package.json b/package.json index 9e6059d..6f2c90d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup-plugin-sass", - "version": "1.2.13", + "version": "1.2.14", "description": "Rollup Sass files.", "main": "dist/index.js", "typings": "dist/index.d.ts", @@ -57,7 +57,6 @@ }, "dependencies": { "@rollup/pluginutils": "^3.1.0", - "icss-utils": "^5.1.0", "resolve": "^1.5.0", "sass": "^1.7.2" }, @@ -71,6 +70,7 @@ "coveralls": "^3.1.1", "downlevel-dts": "^0.10.0", "eslint": "^7.32.0", + "icss-utils": "^5.1.0", "jsdom": "^17.0.0", "nyc": "^15.1.0", "postcss": "^8.4.16", diff --git a/test/assets/expect_a--with-icss-exports.css b/test/assets/expect_a--with-icss-exports.css index b491714..f480c91 100644 --- a/test/assets/expect_a--with-icss-exports.css +++ b/test/assets/expect_a--with-icss-exports.css @@ -1 +1 @@ -body{color:red;background:blue;} +body{color:red;background:blue} diff --git a/test/index.test.ts b/test/index.test.ts index 7bca199..2aa7fd1 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -299,24 +299,19 @@ test('should support processor return type `Promise<{css: string, icssExport: {} out = Object.assign({}, extractedIcss.icssExports, { css: cleanedCss, }); - console.table(extractedIcss); - console.log(out); + // console.table(extractedIcss); + // console.log(out); resolve(out); }), options: sassOptions, }), ], }), - {output} = await outputBundle.generate(generateOptions); - - outputBundle.write({ - ...generateOptions, - file: path.join(tmpDir, 'with--icss-exports.js'), - }); - // console.log('output:', output); + {output} = await outputBundle.generate(generateOptions), + rslt = squash(unwrap(output)); - t.true(squash(unwrap(output)).includes(expectA2)); - t.true(squash(unwrap(output)).includes(expectB)); + t.true(rslt.includes(expectA2)); + t.true(rslt.includes(expectB)); }); test('should processor throw error', async t => { @@ -482,6 +477,6 @@ test('When `sourcemap` is set, to `true`, adjacent source map file should be out }); test.after(async (): Promise => { - // return fs.rmdir(tmpDir, {recursive: true}) - // .catch(error); + return fs.rmdir(tmpDir, {recursive: true}) + .catch(error); });