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

Build ESM and CommonJS modules #1858

Merged
merged 3 commits into from
Dec 22, 2021
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 12
node-version: 14
- name: Build
run: |
npm ci
npm run init
npm run build
npm run bundle
- name: Test
if: matrix.os != 'ubuntu-latest'
if: matrix.os == 'windows-latest'
run: |
npm run test
- name: Test & Coverage
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dist
lib
docs
*.log
stats.html

.idea/
.vscode/*
Expand Down
9 changes: 9 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## Migrating to JSON Forms 3.0 for React users

### Removal of React Material extended renderer set

Previously we maintained a separate 'extended' renderer set to not force all consumers of JSON Forms to consume the Material UI lab dependency.
With the update to Material UI v5 the lab dependency became more important as it also contains all date and time pickers.
Therefore we now require the lab dependency and removed the no longer needed extended renderer set.

If you consumed the extended renderer set then just revert to the normal renderer set.
There should not be any behavior changes.

### Removal of Class Components in React Material

With Version 3.0 of JSON Forms we removed all React Material class components.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ In addition, EclipseSource also offers [professional support](https://jsonforms.

### First time setup

* Install [node.js](https://nodejs.org/) (only Node 12 is currently supported)
* Install [node.js](https://nodejs.org/) (only Node 14 and npm 6 is currently supported)
* Clone this repository
* Install dependencies: `npm ci`
* Hook up dependencies between packages: `npm run init`
Expand Down
3 changes: 1 addition & 2 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"core-js",
"vue",
"rollup-plugin-vue",
"@vue/test-utils",
"@vue/composition-api"
"@vue/test-utils"
]
}
7,230 changes: 2,719 additions & 4,511 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jsonforms-monorepo",
"scripts": {
"lerna": "lerna",
"preparePublish": "git clean -dfx && npm ci && npm run init && npm run clean && npm run build && npm run bundle && npm run test",
"preparePublish": "git clean -dfx && npm ci && npm run init && npm run clean && npm run build && npm run test",
"merge-report": "mkdir -p coverage && lcov-result-merger 'packages/**/coverage/lcov.info' 'coverage/lcov.info'",
"check-format": "echo 'temporarily disabled'",
"init": "lerna bootstrap --hoist",
Expand All @@ -14,7 +14,10 @@
"lint": "tslint 'packages/**/*.{ts,tsx}' -c ./tslint.json"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "0.1.3",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.5",
"@babel/plugin-proposal-optional-chaining": "^7.16.5",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"istanbul-lib-coverage": "^3.2.0",
"@types/jest": "^24.0.23",
"@types/lodash": "^4.14.149",
"ajv": "^8.6.1",
Expand All @@ -28,13 +31,13 @@
"lcov-result-merger": "^3.1.0",
"lerna": "^3.19.0",
"nan": "^2.14.2",
"nyc": "^14.1.1",
"nyc": "^15.1.0",
"prettier": "^1.19.1",
"source-map-loader": "^0.2.4",
"source-map-support": "0.5.16",
"style-loader": "^1.0.1",
"ts-loader": "^6.2.1",
"ts-node": "^8.5.3",
"ts-node": "^10.4.0",
"tslint": "^5.20.1",
"tslint-loader": "^3.5.4",
"tslint-react": "^4.1.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/angular-material/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
"layout",
"customization"
],
"main": "./lib/index.js",
"typings": "./lib/index.d.ts",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
"typings": "./lib/esm/index.d.ts",
"scripts": {
"bundle": "webpack --config webpack/webpack.build.js --env=production --display-error-details",
"build": "ngc",
"build": "ngc && ngc -p tsconfig.cjs.json",
"dev": "webpack --config webpack/webpack.dev.js && webpack-dev-server --config webpack/webpack.dev.js --env=dev --inline",
"clean": "rimraf lib coverage dist .nyc_output 2> /dev/null",
"lint": "tslint --project tsconfig.json --exclude src/models/jsonSchema.ts",
Expand Down Expand Up @@ -105,7 +105,7 @@
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^3.0.5",
"null-loader": "^0.1.1",
"nyc": "^14.1.1",
"nyc": "^15.1.0",
"protractor": "^5.4.1",
"request": "^2.88.0",
"rimraf": "^3.0.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/*
The MIT License

Copyright (c) 2018-2020 EclipseSource Munich
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -22,34 +22,24 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import React from 'react';
import {
ControlProps,
isEnumControl,
OwnPropsOfEnum,
RankedTester,
rankWith,
} from '@jsonforms/core';
import { withJsonFormsEnumProps } from '@jsonforms/react';
import { MuiSelect } from '../mui-controls/MuiSelect';
import merge from 'lodash/merge';
import { MaterialInputControl } from '../controls/MaterialInputControl';
import { MuiAutocomplete, WithOptionLabel } from './MuiAutocomplete';
import { ControlElement, getAjv, getData, isVisible, JsonFormsState, OwnPropsOfRenderer } from '@jsonforms/core';

export const MaterialAutocompleteEnumControl = (props: ControlProps & OwnPropsOfEnum & WithOptionLabel) => {
const {config, uischema} = props;
const appliedUiSchemaOptions = merge({}, config, uischema.options);
return (
<MaterialInputControl
{...props}
input={appliedUiSchemaOptions.autocomplete === false ? MuiSelect : MuiAutocomplete}
/>
);
};
export const controlWithoutLabel = (scope: string): ControlElement => ({
type: 'Control',
scope: scope,
label: false
});

export const materialAutocompleteEnumControlTester: RankedTester = rankWith(
10,
isEnumControl
);
export const mapStateToVisible = (
state: JsonFormsState,
ownProps: OwnPropsOfRenderer
) => {
const visible =
ownProps.visible !== undefined
? ownProps.visible
: isVisible(ownProps.uischema, getData(state), undefined, getAjv(state));

export default withJsonFormsEnumProps(MaterialAutocompleteEnumControl);
return {
visible
};
};
14 changes: 13 additions & 1 deletion packages/angular-material/test-config/webpack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@ module.exports = {
},

module: {
rules: [{
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
options: {
plugins: [
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator'
]
},
exclude: /node_modules/
},
{
test: /\.ts$/,
loaders: [
{
Expand Down
9 changes: 9 additions & 0 deletions packages/angular-material/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"outDir": "./lib/cjs",
"sourceMap": true,
"target": "es5",
"module": "commonjs"
},
}
5 changes: 3 additions & 2 deletions packages/angular-material/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"extends": "../../tsconfig.base",
"compilerOptions": {
"outDir": "./lib",
"sourceMap": true
"outDir": "./lib/esm",
"sourceMap": true,
"target": "es5"
},
"exclude": ["node_modules"],
"files": ["./src/index.ts"],
Expand Down
20 changes: 9 additions & 11 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@
"layout",
"customization"
],
"main": "./lib/index.js",
"typings": "./lib/index.d.ts",
"main": "./lib/cjs/index.js",
"esm": "./lib/esm/index.js",
"typings": "./lib/esm/index.d.ts",
"scripts": {
"bundle": "webpack --config ./webpack.build.js --env=production --display-error-details",
"build": "ngc",
"build": "ngc && ngc -p tsconfig.cjs.json",
"clean": "rimraf lib coverage dist .nyc_output 2> /dev/null",
"lint": "tslint --project tsconfig.json --exclude src/models/jsonSchema.ts",
"report": "nyc report --reporter=html",
"test": "ava",
"test-cov": "nyc ava",
"test": "cross-env TS_NODE_COMPILER_OPTIONS={\\\"module\\\":\\\"commonjs\\\"} ava",
"test-cov": "cross-env TS_NODE_COMPILER_OPTIONS={\\\"module\\\":\\\"commonjs\\\"} nyc ava",
"doc": "typedoc --name 'JSON Forms Angular Core' --mode file --out docs src"
},
"nyc": {
Expand Down Expand Up @@ -74,13 +74,11 @@
"@jsonforms/core": "^3.0.0-alpha.3",
"ava": "~2.4.0",
"copy-webpack-plugin": "^5.0.5",
"nyc": "^14.1.1",
"cross-env": "^7.0.2",
"nyc": "^15.1.0",
"rimraf": "^3.0.2",
"rxjs": "^6.4.0",
"tslint": "^5.20.1",
"typedoc": "^0.19.2",
"webpack": "^4.41.2",
"webpack-cli": "^3.2.1",
"webpack-dev-server": "^3.9.0"
"typedoc": "^0.19.2"
}
}
9 changes: 9 additions & 0 deletions packages/angular/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"outDir": "./lib/cjs",
"sourceMap": true,
"target": "es5",
"module": "commonjs"
},
}
5 changes: 3 additions & 2 deletions packages/angular/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"extends": "../../tsconfig.base",
"compilerOptions": {
"outDir": "./lib",
"sourceMap": true
"outDir": "./lib/esm",
"sourceMap": true,
"target": "es5"
},
"exclude": ["node_modules"],
"files": ["./src/index.ts"],
Expand Down
12 changes: 0 additions & 12 deletions packages/angular/webpack.build.js

This file was deleted.

25 changes: 14 additions & 11 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@
"layout",
"customization"
],
"main": "./lib/index.js",
"main": "lib/jsonforms-core.cjs.js",
"module": "lib/jsonforms-core.esm.js",
"typings": "./lib/index.d.ts",
"scripts": {
"bundle": "webpack --config ./webpack.build.js --env=production --display-error-details",
"build": "tsc",
"build": "rollup -c rollup.config.js",
"clean": "rimraf -rf lib coverage dist .nyc_output 2> /dev/null",
"lint": "tslint --project tsconfig.json --exclude src/models/jsonSchema.ts",
"report": "nyc report --reporter=html",
"test": "ava",
"test-cov": "rimraf -rf .nyc_output && nyc ava",
"test": "cross-env TS_NODE_COMPILER_OPTIONS={\\\"module\\\":\\\"commonjs\\\",\\\"target\\\":\\\"es5\\\"} ava",
"test-cov": "rimraf -rf .nyc_output && cross-env TS_NODE_COMPILER_OPTIONS={\\\"module\\\":\\\"commonjs\\\",\\\"target\\\":\\\"es5\\\"} nyc ava",
"doc": "typedoc --name 'JSON Forms Core' --mode file --excludeExternals --theme ../../typedoc-jsonforms --out docs src"
},
"ava": {
Expand Down Expand Up @@ -67,22 +67,25 @@
"lodash": "^4.17.15"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "0.1.3",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@types/redux-mock-store": "^1.0.1",
"ava": "~2.4.0",
"cross-env": "^7.0.2",
"document-register-element": "^1.14.3",
"jsdom": "^15.2.1",
"jsdom-global": "^3.0.2",
"nyc": "^14.1.1",
"nyc": "^15.1.0",
"redux": "^4.0.4",
"redux-mock-store": "1.5.3",
"rimraf": "^3.0.2",
"rollup": "^2.7.3",
"rollup-plugin-typescript2": "^0.31.1",
"rollup-plugin-visualizer": "^5.4.1",
"rollup-plugin-cleanup": "^3.2.1",
"source-map-support": "0.5.16",
"ts-node": "^8.5.3",
"ts-node": "^10.4.0",
"tslint": "^5.20.1",
"typedoc": "^0.19.2",
"typescript": "4.2.3",
"webpack": "^4.41.2",
"webpack-cli": "^3.2.1"
"typescript": "4.2.3"
}
}
Loading