Skip to content

Instantly share code, notes, and snippets.

@noseratio
Last active October 24, 2020 03:16
Show Gist options
  • Select an option

  • Save noseratio/c4f2a6b92ee6024fde3ef95c1ebad147 to your computer and use it in GitHub Desktop.

Select an option

Save noseratio/c4f2a6b92ee6024fde3ef95c1ebad147 to your computer and use it in GitHub Desktop.
Adding Acorn plugins to Snowpack workflow
"use strict";
// https://stackoverflow.com/a/64501702/1768303
module.exports = function plugin(snowpackConfig, pluginOptions) {
const name = "rollup-acorn-conf";
snowpackConfig.installOptions = snowpackConfig.installOptions ?? {};
snowpackConfig.installOptions.rollup = snowpackConfig.installOptions.rollup ?? {};
snowpackConfig.installOptions.rollup.plugins = snowpackConfig.installOptions.rollup.plugins ?? [];
snowpackConfig.installOptions.rollup.plugins.push({
name,
options: rollupOpts => {
console.log("Enabling 'acorn-stage3'...");
rollupOpts.acorn = rollupOpts.acorn ?? {};
rollupOpts.acorn.ecmaVersion = 2020;
rollupOpts.acornInjectPlugins = rollupOpts.acornInjectPlugins ?? [];
rollupOpts.acornInjectPlugins.push(require('acorn-stage3'));
return rollupOpts;
}
});
return { name };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment