diff --git a/.travis.yml b/.travis.yml index 5737015..d669492 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: node_js node_js: - - "0.12" - - "0.10" - - "iojs" + - 4 + - 6 diff --git a/package.json b/package.json index c3e7e90..01f795d 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,26 @@ { "name": "css-modules-loader-core", - "version": "1.0.0", + "version": "1.1.0", "description": "A loader-agnostic CSS Modules implementation, based on PostCSS", "main": "lib/index.js", "directories": { "test": "test" }, "dependencies": { - "icss-replace-symbols": "1.0.2", - "postcss": "5.0.10", - "postcss-modules-values": "1.1.2", - "postcss-modules-extract-imports": "1.0.0", - "postcss-modules-local-by-default": "1.0.1", - "postcss-modules-scope": "1.0.0" + "icss-replace-symbols": "1.1.0", + "postcss": "6.0.1", + "postcss-modules-extract-imports": "1.1.0", + "postcss-modules-local-by-default": "1.2.0", + "postcss-modules-scope": "1.1.0", + "postcss-modules-values": "1.3.0" }, "devDependencies": { "babel": "5.8.29", - "babel-eslint": "4.1.3", - "babelify": "6.4.0", + "babel-eslint": "7.1.0", + "babelify": "7.3.0", "chokidar-cli": "1.1.0", - "eslint": "1.7.2", - "mocha": "2.3.3" + "eslint": "3.10.1", + "mocha": "3.1.2" }, "scripts": { "lint": "eslint src", diff --git a/src/file-system-loader.js b/src/file-system-loader.js index 2a3f47d..e26c2c0 100644 --- a/src/file-system-loader.js +++ b/src/file-system-loader.js @@ -23,6 +23,7 @@ export default class FileSystemLoader { constructor( root, plugins ) { this.root = root this.sources = {} + this.traces = {} this.importNr = 0 this.core = new Core(plugins) this.tokensByFile = {}; @@ -51,7 +52,8 @@ export default class FileSystemLoader { if ( err ) reject( err ) this.core.load( source, rootRelativePath, trace, this.fetch.bind( this ) ) .then( ( { injectableSource, exportTokens } ) => { - this.sources[trace] = injectableSource + this.sources[fileRelativePath] = injectableSource + this.traces[trace] = fileRelativePath this.tokensByFile[fileRelativePath] = exportTokens resolve( exportTokens ) }, reject ) @@ -60,7 +62,16 @@ export default class FileSystemLoader { } get finalSource() { - return Object.keys( this.sources ).sort( traceKeySorter ).map( s => this.sources[s] ) - .join( "" ) + const traces = this.traces + const sources = this.sources + let written = new Set() + + return Object.keys( traces ).sort( traceKeySorter ).map(key => { + const filename = traces[key] + if (written.has(filename)) { return null } + written.add(filename) + + return sources[filename]; + }).join( "" ) } } diff --git a/test/test-cases/values/source.css b/test/test-cases/values/source.css index 2c63c32..3953a8d 100644 --- a/test/test-cases/values/source.css +++ b/test/test-cases/values/source.css @@ -1,4 +1,5 @@ -@value borders: "./borders.css", breakpoints: "./breakpoints.css"; +@value borders: "./borders.css"; +@value breakpoints: "./breakpoints.css"; @value small, medium from breakpoints; @value secondary, primary as blue from "./colors.css";