Skip to content

Commit ef7c79a

Browse files
committed
Build ESM and CommonJS modules
Use Rollup to bundle ESM and CommonJS modules for all non-Angular packages. Angular builds are done via ngc. ESM bundles target 'esnext' while CommonJS bundles continue to target ES5. Also adjusts Vue dependencies so that Vue and the respective template compiler are of the same version.
1 parent 81f1f19 commit ef7c79a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3764
-5438
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ dist
55
lib
66
docs
77
*.log
8+
stats.html
89

910
.idea/
1011
.vscode/*

lerna.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"core-js",
1010
"vue",
1111
"rollup-plugin-vue",
12-
"@vue/test-utils",
13-
"@vue/composition-api"
12+
"@vue/test-utils"
1413
]
1514
}

package-lock.json

Lines changed: 2157 additions & 4051 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "jsonforms-monorepo",
33
"scripts": {
44
"lerna": "lerna",
5-
"preparePublish": "git clean -dfx && npm ci && npm run init && npm run clean && npm run build && npm run bundle && npm run test",
5+
"preparePublish": "git clean -dfx && npm ci && npm run init && npm run clean && npm run build && npm run test",
66
"merge-report": "mkdir -p coverage && lcov-result-merger 'packages/**/coverage/lcov.info' 'coverage/lcov.info'",
77
"check-format": "echo 'temporarily disabled'",
88
"init": "lerna bootstrap --hoist",
@@ -14,6 +14,8 @@
1414
"lint": "tslint 'packages/**/*.{ts,tsx}' -c ./tslint.json"
1515
},
1616
"devDependencies": {
17+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.5",
18+
"@babel/plugin-proposal-optional-chaining": "^7.16.5",
1719
"@istanbuljs/nyc-config-typescript": "0.1.3",
1820
"@types/jest": "^24.0.23",
1921
"@types/lodash": "^4.14.149",
@@ -34,7 +36,7 @@
3436
"source-map-support": "0.5.16",
3537
"style-loader": "^1.0.1",
3638
"ts-loader": "^6.2.1",
37-
"ts-node": "^8.5.3",
39+
"ts-node": "^10.4.0",
3840
"tslint": "^5.20.1",
3941
"tslint-loader": "^3.5.4",
4042
"tslint-react": "^4.1.0",

packages/angular-material/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
"layout",
3131
"customization"
3232
],
33-
"main": "./lib/index.js",
34-
"typings": "./lib/index.d.ts",
33+
"main": "./lib/cjs/index.js",
34+
"module": "./lib/esm/index.js",
35+
"typings": "./lib/esm/index.d.ts",
3536
"scripts": {
36-
"bundle": "webpack --config webpack/webpack.build.js --env=production --display-error-details",
37-
"build": "ngc",
37+
"build": "ngc && ngc -p tsconfig.cjs.json",
3838
"dev": "webpack --config webpack/webpack.dev.js && webpack-dev-server --config webpack/webpack.dev.js --env=dev --inline",
3939
"clean": "rimraf lib coverage dist .nyc_output 2> /dev/null",
4040
"lint": "tslint --project tsconfig.json --exclude src/models/jsonSchema.ts",
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
The MIT License
3+
4+
Copyright (c) 2017-2019 EclipseSource Munich
5+
https://github.com/eclipsesource/jsonforms
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
THE SOFTWARE.
24+
*/
25+
import { ControlElement, getAjv, getData, isVisible, JsonFormsState, OwnPropsOfRenderer } from '@jsonforms/core';
26+
27+
export const controlWithoutLabel = (scope: string): ControlElement => ({
28+
type: 'Control',
29+
scope: scope,
30+
label: false
31+
});
32+
33+
export const mapStateToVisible = (
34+
state: JsonFormsState,
35+
ownProps: OwnPropsOfRenderer
36+
) => {
37+
const visible =
38+
ownProps.visible !== undefined
39+
? ownProps.visible
40+
: isVisible(ownProps.uischema, getData(state), undefined, getAjv(state));
41+
42+
return {
43+
visible
44+
};
45+
};

packages/angular-material/test-config/webpack.test.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,19 @@ module.exports = {
99
},
1010

1111
module: {
12-
rules: [{
12+
rules: [
13+
{
14+
test: /\.jsx?$/,
15+
loader: 'babel-loader',
16+
options: {
17+
plugins: [
18+
'@babel/plugin-proposal-optional-chaining',
19+
'@babel/plugin-proposal-nullish-coalescing-operator'
20+
]
21+
},
22+
exclude: /node_modules/
23+
},
24+
{
1325
test: /\.ts$/,
1426
loaders: [
1527
{
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig",
3+
"compilerOptions": {
4+
"outDir": "./lib/cjs",
5+
"sourceMap": true,
6+
"target": "es5",
7+
"module": "commonjs"
8+
},
9+
}

packages/angular-material/tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"extends": "../../tsconfig.base",
33
"compilerOptions": {
4-
"outDir": "./lib",
5-
"sourceMap": true
4+
"outDir": "./lib/esm",
5+
"sourceMap": true,
6+
"target": "es5"
67
},
78
"exclude": ["node_modules"],
89
"files": ["./src/index.ts"],

packages/angular/package.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@
2929
"layout",
3030
"customization"
3131
],
32-
"main": "./lib/index.js",
33-
"typings": "./lib/index.d.ts",
32+
"main": "./lib/cjs/index.js",
33+
"esm": "./lib/esm/index.js",
34+
"typings": "./lib/esm/index.d.ts",
3435
"scripts": {
35-
"bundle": "webpack --config ./webpack.build.js --env=production --display-error-details",
36-
"build": "ngc",
36+
"build": "ngc && ngc -p tsconfig.cjs.json",
3737
"clean": "rimraf lib coverage dist .nyc_output 2> /dev/null",
3838
"lint": "tslint --project tsconfig.json --exclude src/models/jsonSchema.ts",
3939
"report": "nyc report --reporter=html",
40-
"test": "ava",
41-
"test-cov": "nyc ava",
40+
"test": "cross-env TS_NODE_COMPILER_OPTIONS={\\\"module\\\":\\\"commonjs\\\"} ava",
41+
"test-cov": "cross-env TS_NODE_COMPILER_OPTIONS={\\\"module\\\":\\\"commonjs\\\"} nyc ava",
4242
"doc": "typedoc --name 'JSON Forms Angular Core' --mode file --out docs src"
4343
},
4444
"nyc": {
@@ -74,13 +74,11 @@
7474
"@jsonforms/core": "^3.0.0-alpha.3",
7575
"ava": "~2.4.0",
7676
"copy-webpack-plugin": "^5.0.5",
77+
"cross-env": "^7.0.2",
7778
"nyc": "^14.1.1",
7879
"rimraf": "^3.0.2",
7980
"rxjs": "^6.4.0",
8081
"tslint": "^5.20.1",
81-
"typedoc": "^0.19.2",
82-
"webpack": "^4.41.2",
83-
"webpack-cli": "^3.2.1",
84-
"webpack-dev-server": "^3.9.0"
82+
"typedoc": "^0.19.2"
8583
}
8684
}

0 commit comments

Comments
 (0)