From dc6718efbe76f1e57d3ba5d5ec1f5ff5f5095bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Wed, 21 Oct 2015 19:19:11 -0400 Subject: [PATCH 1/6] Improve dependency parsing (ignore comments, simplify function) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds tests for nested modules and defines with line comments inside. Signed-off-by: Jörn Zaefferer Closes #1 --- index.js | 14 +++++--------- test/fixtures/basic/foo.js | 6 +++++- test/fixtures/nested/theme/input.css | 1 + test/fixtures/nested/theme/version.css | 1 + test/fixtures/nested/version.js | 2 ++ test/fixtures/nested/widgets/input.js | 3 +++ test/index.js | 22 ++++++++++++++++++++++ 7 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 test/fixtures/nested/theme/input.css create mode 100644 test/fixtures/nested/theme/version.css create mode 100644 test/fixtures/nested/version.js create mode 100644 test/fixtures/nested/widgets/input.js diff --git a/index.js b/index.js index 66aab5c..2931289 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ function cssDependencies( data, which ) { regexp = new RegExp( "\\/\\/>>\\s*css\\." + which + ":(.*)", "g" ); data.replace( regexp, function( garbage, input ) { - input = input.split( "," ).map( trim ); + input = input.split( "," ).map( trim ); result.push.apply( result, input ); }); @@ -15,15 +15,11 @@ function cssDependencies( data, which ) { } function jsDependencies( data ) { - var match, - result = []; - - match = data.match( /define\(\[([^\]]*?)\]/ ); - if ( match !== null ) { - result = match[ 1 ].split( "," ).map( trim ); + var match = data.match( /define\(\[([^\]]*?)\]/ ); + if ( match === null ) { + return []; } - - return result; + return match[ 1 ].replace( /\/\/.+/g, "" ).split( "," ).map( trim ); } /** diff --git a/test/fixtures/basic/foo.js b/test/fixtures/basic/foo.js index 52736fc..7052c3c 100644 --- a/test/fixtures/basic/foo.js +++ b/test/fixtures/basic/foo.js @@ -1,2 +1,6 @@ //>> css.baz: ./foo.css -define([ "./bar" ]); +define([ + + // comment + "./bar" +]); diff --git a/test/fixtures/nested/theme/input.css b/test/fixtures/nested/theme/input.css new file mode 100644 index 0000000..c4236fe --- /dev/null +++ b/test/fixtures/nested/theme/input.css @@ -0,0 +1 @@ +input {} diff --git a/test/fixtures/nested/theme/version.css b/test/fixtures/nested/theme/version.css new file mode 100644 index 0000000..208d16d --- /dev/null +++ b/test/fixtures/nested/theme/version.css @@ -0,0 +1 @@ +body {} diff --git a/test/fixtures/nested/version.js b/test/fixtures/nested/version.js new file mode 100644 index 0000000..1ad525d --- /dev/null +++ b/test/fixtures/nested/version.js @@ -0,0 +1,2 @@ +//>> css.structure: ./theme/version.css +define("0.2.0"); diff --git a/test/fixtures/nested/widgets/input.js b/test/fixtures/nested/widgets/input.js new file mode 100644 index 0000000..adcbdaa --- /dev/null +++ b/test/fixtures/nested/widgets/input.js @@ -0,0 +1,3 @@ +//>> css.structure: ../theme/input.css +define(["../version"], function(version) { +}); diff --git a/test/index.js b/test/index.js index bf1e0d0..82bed37 100644 --- a/test/index.js +++ b/test/index.js @@ -49,6 +49,28 @@ describe( "jQuery CSS Builder", function() { }); + describe( "Basic - nested+appdir", function() { + var css, + files = { + "fixtures/version.js": fs.readFileSync( __dirname + "/fixtures/nested/version.js" ), + "fixtures/widgets/input.js": fs.readFileSync( __dirname + "/fixtures/nested/widgets/input.js" ), + "fixtures/theme/version.css": fs.readFileSync( __dirname + "/fixtures/nested/theme/version.css" ), + "fixtures/theme/input.css": fs.readFileSync( __dirname + "/fixtures/nested/theme/input.css" ) + }; + + before(function( done ) { + jQueryCSSBuilder( files, "structure", { appDir: "fixtures", include: [ "widgets/input" ] }, function( error, _css ) { + css = _css; + done( error ); + }); + }); + + it( "should build just fine", function() { + expect( css ).to.equal( "input {}\nbody {}\n" ); + }); + + }); + describe( "Two bundles", function() { var cssNorth, cssSouth; var files = { From 79d7d27145c6d6d4d51bcbeaf872add6931f571c Mon Sep 17 00:00:00 2001 From: Rafael Xavier de Souza Date: Fri, 23 Oct 2015 13:51:17 -0200 Subject: [PATCH 2/6] 0.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 238c7ac..3b15573 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "builder-jquery-css", - "version": "0.0.2", + "version": "0.0.3", "main": "index.js", "repository": { "type": "git", From 79705fb4fdd59a1b927e6a30f140c3c8959d7631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Wed, 28 Oct 2015 10:31:42 +0100 Subject: [PATCH 3/6] Fix dependency parsing, allow space inside parameter list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Zaefferer --- index.js | 2 +- test/fixtures/nested/version.js | 2 +- test/fixtures/nested/widgets/input.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 2931289..de910d8 100644 --- a/index.js +++ b/index.js @@ -15,7 +15,7 @@ function cssDependencies( data, which ) { } function jsDependencies( data ) { - var match = data.match( /define\(\[([^\]]*?)\]/ ); + var match = data.match( /define\(\ ?\[([^\]]*?)\]/ ); if ( match === null ) { return []; } diff --git a/test/fixtures/nested/version.js b/test/fixtures/nested/version.js index 1ad525d..3af1221 100644 --- a/test/fixtures/nested/version.js +++ b/test/fixtures/nested/version.js @@ -1,2 +1,2 @@ //>> css.structure: ./theme/version.css -define("0.2.0"); +define( "0.2.0" ); diff --git a/test/fixtures/nested/widgets/input.js b/test/fixtures/nested/widgets/input.js index adcbdaa..d3ca601 100644 --- a/test/fixtures/nested/widgets/input.js +++ b/test/fixtures/nested/widgets/input.js @@ -1,3 +1,3 @@ //>> css.structure: ../theme/input.css -define(["../version"], function(version) { -}); +define( ["../version"], function( version ) { +} ); From 0d09520c2e2766d8749a6532efe00301a5742ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Thu, 29 Oct 2015 10:25:28 +0100 Subject: [PATCH 4/6] 0.0.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3b15573..829939d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "builder-jquery-css", - "version": "0.0.3", + "version": "0.0.4", "main": "index.js", "repository": { "type": "git", From bed0caf6af190f399d03a90957536c172e26c939 Mon Sep 17 00:00:00 2001 From: Rafael Xavier de Souza Date: Mon, 19 Jan 2026 07:17:23 -0300 Subject: [PATCH 5/6] docs: update copyright notice to OpenJS Foundation license --- LICENSE-MIT | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE-MIT b/LICENSE-MIT index 6123def..0672773 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,4 +1,4 @@ -Copyright (c) Rafael Xavier de Souza http://rafael.xavier.blog.br +Copyright OpenJS Foundation and other contributors, https://openjsf.org/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation From ec441952de1b6c14f231880ad8a1d18da65706aa Mon Sep 17 00:00:00 2001 From: Rafael Xavier de Souza Date: Mon, 19 Jan 2026 07:19:17 -0300 Subject: [PATCH 6/6] docs: update copyright notice to OpenJS Foundation license --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c276a47..87dbbe9 100644 --- a/README.md +++ b/README.md @@ -69,4 +69,4 @@ structure. ## License -MIT © [Rafael Xavier de Souza](http://rafael.xavier.blog.br) +MIT © [OpenJS Foundation and other contributors](https://openjsf.org/)