Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate greenwood jsx #1

Merged
merged 20 commits into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
module.exports = {
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module'
ecmaVersion: 2021,
sourceType: 'module',
ecmaFeatures: {
jsx: true
}
},
env: {
browser: true,
node: false
browser: false,
node: true
},
rules: {
'comma-dangle': [2, 'never'],
Expand Down Expand Up @@ -40,7 +43,7 @@ module.exports = {
'valid-jsdoc': 0,
'valid-typeof': 0,
'no-unexpected-multiline': 0,
'accessor-pairs': 2,
'accessor-pairs': 1,
'block-scoped-var': 2,
'complexity': 2,
'consistent-return': 0,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
npm run lint
- name: Test
run: |
npm test
npm run test
- name: Build
run: |
npm run build
28 changes: 28 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Master Integration

on:
push:
branches:
- master

jobs:

build:
runs-on: ubuntu-18.04

strategy:
matrix:
node: [16]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Installing project dependencies
run: |
npm ci
- name: Build
run: |
npm run build
43 changes: 43 additions & 0 deletions greenwood-plugin-import-jsx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
*
* Enables using JavaScript to import JSX files with WCC.
*
*/
import { load } from 'wc-compiler/src/jsx-loader.js';
import { ResourceInterface } from '@greenwood/cli/src/lib/resource-interface.js';
import { pathToFileURL } from 'url';

class JsxResource extends ResourceInterface {
constructor(compilation, options) {
super(compilation, options);
this.extensions = ['.jsx'];
this.contentType = 'text/javascript';
}

async serve(url) {
return new Promise(async (resolve, reject) => {
try {
const result = await load(pathToFileURL(url));

resolve({
body: result.source,
contentType: this.contentType
});
} catch (e) {
reject(e);
}
});
}
}

const greenwoodPluginImportJsx = (options = {}) => {
return [{
type: 'resource',
name: 'plugin-import-jsx:resource',
provider: (compilation) => new JsxResource(compilation, options)
}];
};

export {
greenwoodPluginImportJsx
};
7 changes: 3 additions & 4 deletions greenwood.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { greenwoodPluginImportCss } from '@greenwood/plugin-import-css';
import { greenwoodPluginPostCss } from '@greenwood/plugin-postcss';
import { greenwoodPluginImportJsx } from './greenwood-plugin-import-jsx.js';

export default {
prerender: true,
plugins: [
greenwoodPluginPostCss(),
...greenwoodPluginImportCss()
...greenwoodPluginImportJsx()
]
};
9 changes: 0 additions & 9 deletions netlify.toml

This file was deleted.

Loading