Skip to content

Commit

Permalink
Merge pull request #10 from fpauser/migrate-to-postcss-8
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreeman authored May 17, 2021
2 parents 6f3e7d5 + c9259c9 commit 2731a00
Show file tree
Hide file tree
Showing 6 changed files with 1,033 additions and 1,085 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "8"
- "10"
- "node"

cache:
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "10"
- nodejs_version: "12"

install:
- ps: Install-Product node $env:nodejs_version
Expand Down
22 changes: 12 additions & 10 deletions lib/link-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@
*/

const Promise = require('rsvp').Promise;
const postcss = require('postcss');
const replaceSymbols = require('icss-replace-symbols').default;

module.exports = postcss.plugin('link-modules', (options) => {
return (css, result) => {
let translations = {};
let exportTokens = result.exportTokens = {};
module.exports = (options) => {
return {
postcssPlugin: 'link-modules',
Once (css, { result }) {
let translations = {};
let exportTokens = result.exportTokens = {};

return Promise.all(fetchAllImports(css, translations, options))
.then(replaceSymbols.bind(null, css, translations))
.then(extractExports.bind(null, css, translations, exportTokens));
};
});
return Promise.all(fetchAllImports(css, translations, options))
.then(replaceSymbols.bind(null, css, translations))
.then(extractExports.bind(null, css, translations, exportTokens));
}
}
};

const IMPORT_REGEXP = /^:import\((.+)\)$/;

Expand Down
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"url": "git+ssh://[email protected]/salsify/broccoli-css-modules.git"
},
"engines": {
"node": ">= 6"
"node": ">= 10"
},
"author": "Dan Freeman",
"license": "MIT",
Expand All @@ -29,23 +29,26 @@
"ensure-posix-path": "^1.1.1",
"icss-replace-symbols": "^1.0.2",
"mkdirp": "^0.5.1",
"postcss": "^6.0.0 || ^7.0.18",
"postcss-modules-extract-imports": "^1.2.0",
"postcss-modules-local-by-default": "^1.2.0",
"postcss-modules-scope": "^1.1.0",
"postcss-modules-values": "^1.3.0",
"postcss-modules-extract-imports": "^3.0.0",
"postcss-modules-local-by-default": "^4.0.0",
"postcss-modules-scope": "^3.0.0",
"postcss-modules-values": "^4.0.0",
"rsvp": "^4.8.5",
"symlink-or-copy": "^1.1.6"
},
"devDependencies": {
"broccoli": "^2.0.1",
"broccoli-fixture": "^1.0.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"eslint": "^5.0.0",
"chai-as-promised": "^7.1.0",
"eslint": "^7.13.0",
"fs-extra": "^7.0.1",
"mocha": "^6.2.1",
"postcss-scss": "^2.0.0",
"sinon": "^7.5.0"
"mocha": "^8.2.0",
"postcss": "^8.1.0",
"postcss-scss": "^3.0.0",
"sinon": "^2.3.4"
},
"peerDependencies": {
"postcss": "^8.1.0"
}
}
5 changes: 3 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const CSSModules = require('./index');
const { Builder } = require('broccoli');
const os = require('os');
const fs = require('fs-extra');
const path = require('path');

const Node = fixture.Node;

Expand Down Expand Up @@ -595,7 +596,7 @@ it('honors the sourceMapBaseDir when configured', function() {
sources: ['baz/base.css'],
names: [],
mappings: 'AAAA,2BAAQ',
file: 'baz/base.css',
file: path.join('baz', 'base.css'),
sourcesContent: ['.green {}']
}),
'base.js': jsOutput({
Expand Down Expand Up @@ -735,6 +736,6 @@ function mappedCSSOutput(lines, sourcemap) {
}

function sourceMapComment(json) {
let content = new Buffer(JSON.stringify(json), 'utf-8').toString('base64');
let content = new Buffer.from(JSON.stringify(json), 'utf-8').toString('base64');
return '/*# sourceMappingURL=data:application/json;base64,' + content + ' */';
}
Loading

0 comments on commit 2731a00

Please sign in to comment.