Skip to content

Commit

Permalink
feat(build): add basic JSX support
Browse files Browse the repository at this point in the history
so far only *html.jsx is supported and no examples or tests are included

implements #203
  • Loading branch information
trieloff committed May 9, 2019
1 parent 93cdc15 commit aec4c8e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/build.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class BuildCommand extends AbstractCommand {
bundler.addAssetType('htl', require.resolve('@adobe/parcel-plugin-htl/src/HTLAsset.js'));
bundler.addAssetType('helix-js', require.resolve('./parcel/HelixAsset.js'));
bundler.addAssetType('js', require.resolve('./parcel/AdapterJSAsset.js'));
bundler.addAssetType('jsx', require.resolve('./parcel/AdapterJSAsset.js'));
bundler.addAssetType('helix-pre-js', require.resolve('./parcel/ProxyJSAsset.js'));
bundler.addPackager('js', RawJSPackager);
return bundler;
Expand Down
8 changes: 7 additions & 1 deletion src/parcel/AdapterJSAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@
const path = require('path');
const JSAsset = require('parcel-bundler/src/assets/JSAsset');

const PURE_JS_SCRIPTS = ['html.js', 'json.js', 'xml.js', 'svg.js', 'css.js', 'txt.js'];
const PURE_JS_SCRIPTS = ['html.js', 'json.js', 'xml.js', 'svg.js', 'css.js', 'txt.js', 'html.jsx'];

/**
* Adapts Pure-JS actions to the `helix-js` type so that it can be wrapped via the `HelixAsset.js`.
*/
class AdapterJSAsset extends JSAsset {
async getPackage() {
const pkg = await super.getPackage();
pkg.devDependencies.hyperapp = '*';
return pkg;
}

async generate() {
const gen = await super.generate();

Expand Down
5 changes: 5 additions & 0 deletions src/parcel/OutputTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@

/* eslint-disable */

const h = require('hyperscript');


// CONTENTS


function helix_wrap_action(main) {
const { OpenWhiskAction } = require('@adobe/helix-pipeline');
const { pipe } = require('MOD_PIPE');
Expand All @@ -25,6 +29,7 @@ function helix_wrap_action(main) {
async function once(payload, action) {
// calls the pre function and then the script's main.
async function invoker(next) {
console.log('invoking', next);
const ret = await Promise.resolve(pre(payload, action));
return Promise.resolve(next(ret || payload, action));
}
Expand Down

0 comments on commit aec4c8e

Please sign in to comment.