Skip to content

Commit

Permalink
馃殌 v1.1.0 Add support for lazy compilation via compileOneFileLater
Browse files Browse the repository at this point in the history
More info on lazy compilation here: meteor/meteor#9983
  • Loading branch information
coagmano committed Oct 10, 2018
1 parent 1581fb0 commit c2f867f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
13 changes: 11 additions & 2 deletions README.md
@@ -1,11 +1,20 @@
# coagmano:stylus

A fork of `meteor:stylus` including the stylus plugins from `mquandalle:stylus`

`mquandalle:stylus` was failing when using the `import` syntax as part of `ecmascript` modules, so I forked the excellent `meteor:stylus` package which supports ecmascript and caching and added the same stylus plugins that `mquandalle:stylus` used so it is backwards compatible with `mquandalle:stylus`.
`mquandalle:stylus` was failing when using the `import` syntax as part of
`ecmascript` modules, so I forked the excellent `meteor:stylus` package which
supports ecmascript and caching and added the same stylus plugins that
`mquandalle:stylus` used so it is backwards compatible with `mquandalle:stylus`.

### 1.1.0 Update

This project now supports Meteor 1.8's lazy compilation via the
`compileOneFileLater` method ([Meteor PR#9983](https://github.com/meteor/meteor/pull/9983))

## Included packages

### [Stylus](http://stylus-lang.com/) 0.54.5
### [Stylus](http://stylus-lang.com/) 0.54.5 (Meteor's fork)

Expressive, dynamic, robust CSS. Curly braces and semicolons: optional.

Expand Down
6 changes: 3 additions & 3 deletions package.js
@@ -1,13 +1,13 @@
Package.describe({
name: 'coagmano:stylus',
version: '1.0.3',
version: '1.1.0',
summary: 'Stylus plugin with plugins from mquandalle:stylus. Compatible with Meteor 1.4 and \'ecmascript\'',
git: 'https://github.com/coagmano/meteor-stylus.git'
});

Package.registerBuildPlugin({
name: 'compileStylusBatch',
use: ['ecmascript@0.1.4', 'caching-compiler@1.0.0'],
use: ['ecmascript', 'caching-compiler'],
sources: [
'plugin/compile-stylus.js'
],
Expand All @@ -23,7 +23,7 @@ Package.registerBuildPlugin({
});

Package.onUse(function (api) {
api.use('isobuild:compiler-plugin@1.0.0');
api.use('isobuild:compiler-plugin');
});

Package.onTest(function (api) {
Expand Down
19 changes: 17 additions & 2 deletions plugin/compile-stylus.js
Expand Up @@ -28,8 +28,8 @@ class StylusCompiler extends MultiFileCachingCompiler {
getCacheKey(inputFile) {
// prettier-ignore
return [
inputFile.getSourceHash(),
inputFile.getFileOptions(),
inputFile.getArch(),
inputFile.getSourceHash()
];
}

Expand All @@ -53,6 +53,21 @@ class StylusCompiler extends MultiFileCachingCompiler {
return !/\.import\.styl$/.test(pathInPackage);
}

compileOneFileLater(inputFile, getResult) {
// prettier-ignore
inputFile.addStylesheet({
path: inputFile.getPathInPackage(),
}, async () => {
const result = await getResult();
return (
result && {
data: result.css,
sourceMap: result.sourceMap,
}
);
}
);
}
compileOneFile(inputFile, allFiles) {
const referencedImportPaths = [];

Expand Down

0 comments on commit c2f867f

Please sign in to comment.