@datagraphics/baker
Advanced tools
Changelog
[0.34.0] - 2021-06-23
FileSystemLoader
for node_modules
imports (very similar to how Sass engine works via includePaths
), instead of deferring to NodeResolveLoader
. That loader is not nearly as useful when npm
installed packages use the new "export": { ... }
format. Unless packages explicitly declare the non-JS exports you're unable to find them. I don't think we were using that anyway, so it's NBD.Changelog
[0.33.0] - 2021-05-05
svelteCompilerOptions
in baker.config.js
. Good for the rare case of when you need to render them as hydratable.Changelog
[0.32.1] - 2021-04-27
datasetPlugin
and dataPlugin
have been moved to before @rollup/plugin-node-resolve
in the Rollup plugin list. In some cases nodeResolve
would misinterpret the *:
prefix and blow up the path before these plugins got a chance to do it first.Changelog
[0.32.0] - 2021-04-14
{% static %}
tag will now pass through full URLs as-is when used as the parameter. This lets developers not have to worry about whether a path is project relative or not in loops, and allows templates that work with files to easily account for local and remote files.Changelog
[0.31.2] - 2021-02-22
preventAssignment: true
to @rollup/plugin-replace
options.process.exit(1)
is called when builds fail.Changelog
[0.31.1] - 2021-01-31
Changelog
[0.31.0] - 2021-01-22
@web/rollup-plugin-import-meta-assets
it's now possible to import paths to files within JavaScript and have that be enough to ensure that the file is added to the build. This is yet another method for loading data in baker projects, and likely the best one yet.// Rollup will see this and understand it should add this file to your build
const url = new URL('./data/cities.json', import.meta.url);
// load it and go!
const data = await d3.json(url);
Changelog
[0.30.0] - 2021-01-18
A new experimental custom Rollup plugin has been added that provides an optimized method for importing data files in JavaScript. If a JSON, CSV, or TSV file is imported using the prefix dataset:*
it will be added to the bundle either directly as an Object or Array literal (if under 10K in size) or rendered as a string within a JSON.parse
call.
It has been documented that parsing a string within JSON.parse
is much, much faster on average than directly passing in JavaScript, and typically this is the very first step when data is being loaded manually (with d3-fetch
's json
or csv
functions, etc.). This makes it possible to import (or even better — dynamically import) data without having to deploy it as a file or inject it into HTML to be parsed.
An example of how to use it:
import data from 'dataset:./assets/data.json';
// or dynamically
const data = await import('dataset:./assets/data.json');
Changelog
[0.29.0] - 2021-01-13
{% script %}
entrypoint bundle that is added to a page.page
template context object (previously current_page
) - in addition to page.absoluteUrl
, page.url
represents the project-relative URL. page.inputPath
represents the project-relative path to the original input template, and page.outputPath
represents the project-relative output path.current_page
template context object has been renamed to page
. current_page
however will continue to exist until 1.0
.Changelog
[0.28.0] - 2020-12-30
{% custom variable1, variable2 %}
) to Nunjucks via the baker.config.js
file. It is very similar to how you add custom filters.How to add one:
// baker.config.js
module.exports = {
// ...
nunjucksTags: {
author(firstName, lastName) {
return `<p class="author">By ${firstName} ${lastName}</p>`;
},
},
};
How to use one:
{% author "Arthur", "Barker" %}
Heads up! Nunjucks requires a comma between arguments.
And the output:
<p class="author">By Arthur Barker</p>
inject
tag was async it now returns a Promise to match the new interface.