Skip to content

Commit

Permalink
dep fix, scope issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jescalan committed Feb 22, 2017
1 parent 099f917 commit ffe7993
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ new Records({
blog: {
url: 'http://blog.com/api/posts',
template: {
path: 'templates/single.sml',
path: 'templates/single.sgr',
output: (post) => { return `posts/${post.slug}.html` }
}
}
Expand Down
10 changes: 5 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ function writeTemplates (compilation, compiler, _data, k) {
return W.map(data, (item) => {
// The template gets all the default locals as well as an "item" prop
// that contains the data specific to the template, and a filename
Object.assign(this.opts.addDataTo, {
const newLocals = Object.assign({}, this.opts.addDataTo, {
item,
filename: path.join(root, tpl.path)
})

// We need to prceisely replicate the way reshape is set up internally
// We need to precisely replicate the way reshape is set up internally
// in order to render the template correctly, so we run the reshape
// loader's options parsing with the real loader context and the user's
// reshape options from the config
Expand All @@ -187,14 +187,14 @@ function writeTemplates (compilation, compiler, _data, k) {
// And finally, we run reshape to generate the template!
return reshape(options)
.process(template)
.then(((locals, res) => {
const rendered = res.output(locals)
.then((res) => {
const rendered = res.output(newLocals)
// And then add the generated template to webpack's output assets
compilation.assets[tpl.output(item)] = {
source: () => rendered,
size: () => rendered.length
}
}).bind(null, Object.assign({}, options.locals)))
})
})
})
}
15 changes: 12 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2898,14 +2898,14 @@ js-tokens@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7"

js-yaml@3.6.1, js-yaml@^3.4.5:
js-yaml@3.6.1, js-yaml@^3.4.5, js-yaml@^3.5.1:
version "3.6.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.6.1.tgz#6e5fe67d8b205ce4d22fad05b7781e8dadcc4b30"
dependencies:
argparse "^1.0.7"
esprima "^2.6.0"

js-yaml@^3.4.3, js-yaml@^3.5.1, js-yaml@~3.7.0:
js-yaml@^3.4.3, js-yaml@~3.7.0:
version "3.7.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.7.0.tgz#5c967ddd837a9bfdca5f2de84253abe8a1c03b80"
dependencies:
Expand Down Expand Up @@ -3938,7 +3938,7 @@ postcss-load-plugins@^2.3.0:
cosmiconfig "^2.1.1"
object-assign "^4.1.0"

"postcss-loader@github:jescalan/postcss-loader":
postcss-loader@jescalan/postcss-loader:
version "1.2.2"
resolved "https://codeload.github.com/jescalan/postcss-loader/tar.gz/1a8e508c56ac2ce1742d5e93e51926b31578a056"
dependencies:
Expand Down Expand Up @@ -4916,6 +4916,15 @@ spike-core@next:
webpack "^2.2.1"
when "^3.7.7"

spike-util@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/spike-util/-/spike-util-0.4.0.tgz#b2797a0c261db119c86de80cc073ca7c6f6eefb9"
dependencies:
filewrap "0.1.0"
glob "^7.0.4"
micromatch "^2.3.8"
when "^3.7.7"

spike-util@next:
version "0.5.0-0"
resolved "https://registry.yarnpkg.com/spike-util/-/spike-util-0.5.0-0.tgz#0d3eb085bebef1326fc85dc0520585df9de6f28e"
Expand Down

0 comments on commit ffe7993

Please sign in to comment.