From f9518f6dcdc5fc643832f6182c421dcf2f68ef43 Mon Sep 17 00:00:00 2001 From: Michael Williams Date: Thu, 15 Dec 2016 13:08:55 +1300 Subject: [PATCH 1/2] fix dynamic insert-css usage uses forked version of `static-module`: https://github.com/substack/static-module/pull/22 fixes https://github.com/yoshuawuyts/bankai/issues/109 --- package.json | 2 +- test/index.js | 23 +++++++++++++++++++++++ test/source-dynamic-2.js | 7 +++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/source-dynamic-2.js diff --git a/package.json b/package.json index d3beaad..813394e 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dependencies": { "bl": "^1.1.2", "from2-string": "^1.1.0", - "static-module": "^1.3.0", + "static-module": "github:ahdinosaur/static-module#dynamic", "through2": "^2.0.1" }, "devDependencies": { diff --git a/test/index.js b/test/index.js index 1afa789..fe99c88 100644 --- a/test/index.js +++ b/test/index.js @@ -108,4 +108,27 @@ test('css-extract', function (t) { t.ok(String(data).indexOf(String(source)) !== -1, 'source is still in built bundle') } }) + + t.test('should not extract dynamic insert-css statements, again', function (t) { + t.plan(4) + const sourcePath = path.join(__dirname, 'source-dynamic-2.js') + + browserify(sourcePath) + .plugin(cssExtract, { out: readCss }) + .bundle(readJs) + + function readCss () { + return bl(function (err, data) { + t.ifError(err, 'no error') + t.equal(String(data), '', 'no css extracted') + }) + } + + function readJs (err, data) { + t.ifError(err, 'no error') + const source = fs.readFileSync(sourcePath, 'utf8') + console.log(String(data), source) + t.ok(String(data).indexOf(String(source)) !== -1, 'source is still in built bundle') + } + }) }) diff --git a/test/source-dynamic-2.js b/test/source-dynamic-2.js new file mode 100644 index 0000000..fd696d4 --- /dev/null +++ b/test/source-dynamic-2.js @@ -0,0 +1,7 @@ +var insertCss = require('insert-css') + +insert('.foo {}') + +function insert (foo) { + insertCss(foo) +} From 5b6556643f076d03117ff89eec77e0abb236740a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9e=20Kooi?= Date: Thu, 6 Aug 2020 19:43:33 +0200 Subject: [PATCH 2/2] rm console.log --- test/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/index.js b/test/index.js index fe99c88..138c9cf 100644 --- a/test/index.js +++ b/test/index.js @@ -127,7 +127,6 @@ test('css-extract', function (t) { function readJs (err, data) { t.ifError(err, 'no error') const source = fs.readFileSync(sourcePath, 'utf8') - console.log(String(data), source) t.ok(String(data).indexOf(String(source)) !== -1, 'source is still in built bundle') } })