diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07e6e47 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/node_modules diff --git a/LightScriptAsset.js b/LightScriptAsset.js new file mode 100644 index 0000000..21f4a02 --- /dev/null +++ b/LightScriptAsset.js @@ -0,0 +1,15 @@ +const JSAsset = require('parcel-bundler/src/assets/JSAsset') +const babylon = require('babylon-lightscript') + +module.exports = class LightScriptAsset extends JSAsset { + async parse (code) { + const options = await super.getParserOptions() + options.plugins = options.plugins + ? options.plugins.concat('lightscript') + : ['lightscript'] + + this.contents = babylon.parse(code, options); + + return super.parse(this.contents) + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..a0d9e55 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# parcel plugin lightscript + +an example parcel plugin for loading lightscript + + +## usage + +``` +$ yarn add parcel-plugin-lightscript babel-plugin-lightscript + +``` + +then import an `lsc` file, or `