@nebula.js/cli-build 2.1.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.4.1](https://github.com/qlik-oss/nebula.js/compare/v2.4.0...v2.4.1) (2022-02-10)
7
+
8
+ **Note:** Version bump only for package @nebula.js/cli-build
9
+
10
+ # [2.4.0](https://github.com/qlik-oss/nebula.js/compare/v2.3.1...v2.4.0) (2022-02-10)
11
+
12
+ ### Features
13
+
14
+ - add --carbon flag to build react-native supernova packages ([#749](https://github.com/qlik-oss/nebula.js/issues/749)) ([369844d](https://github.com/qlik-oss/nebula.js/commit/369844d722f7fa8873674d9320d7f047065211da))
15
+
16
+ ## [2.3.1](https://github.com/qlik-oss/nebula.js/compare/v2.3.0...v2.3.1) (2021-12-09)
17
+
18
+ ### Bug Fixes
19
+
20
+ - **cli-build:** mitigate problem with require inside try catch blocks ([#729](https://github.com/qlik-oss/nebula.js/issues/729)) ([05abf73](https://github.com/qlik-oss/nebula.js/commit/05abf7384df2831ed32719ac22faf3f25ed6ef5c))
21
+
22
+ # [2.3.0](https://github.com/qlik-oss/nebula.js/compare/v2.2.0...v2.3.0) (2021-12-06)
23
+
24
+ **Note:** Version bump only for package @nebula.js/cli-build
25
+
26
+ # [2.2.0](https://github.com/qlik-oss/nebula.js/compare/v2.1.0...v2.2.0) (2021-11-17)
27
+
28
+ **Note:** Version bump only for package @nebula.js/cli-build
29
+
6
30
  # [2.1.0](https://github.com/qlik-oss/nebula.js/compare/v2.0.0...v2.1.0) (2021-10-20)
7
31
 
8
32
  ### Features
package/lib/build.js CHANGED
@@ -2,6 +2,7 @@ const path = require('path');
2
2
  const chalk = require('chalk');
3
3
  const readline = require('readline');
4
4
 
5
+ const fs = require('fs');
5
6
  const extend = require('extend');
6
7
  const yargs = require('yargs');
7
8
  const rollup = require('rollup');
@@ -18,6 +19,7 @@ const commonjs = require('@rollup/plugin-commonjs');
18
19
  const babelPreset = require('@babel/preset-env');
19
20
 
20
21
  const { terser } = require('rollup-plugin-terser');
22
+ const resolveNative = require('./resolveNative');
21
23
 
22
24
  const initConfig = require('./init-config');
23
25
 
@@ -28,6 +30,22 @@ const resolveReplacementStrings = (replacementStrings) => {
28
30
  return replacementStrings;
29
31
  };
30
32
 
33
+ const setupReactnative = (argv) => {
34
+ const { reactNative } = argv;
35
+ let reactNativePath;
36
+ if (reactNative) {
37
+ reactNativePath = argv.reactNativePath || './react-native';
38
+ if (!fs.existsSync(`${reactNativePath}/package.json`)) {
39
+ // eslint-disable-next-line no-console
40
+ console.warn(
41
+ `WARNING: No ${reactNativePath}/package.json was found. If you really intended to build a react-native version of this package, please provide one.\nOther wise, to supress this warning, omitt the --reactNative flag.`
42
+ );
43
+ return false;
44
+ }
45
+ }
46
+ return { reactNative, reactNativePath };
47
+ };
48
+
31
49
  const config = ({
32
50
  mode = 'production',
33
51
  format = 'umd',
@@ -36,13 +54,17 @@ const config = ({
36
54
  core,
37
55
  } = {}) => {
38
56
  const CWD = argv.cwd || cwd;
57
+ const { reactNative, reactNativePath } = setupReactnative(argv);
39
58
  let dir = CWD;
40
59
  let pkg = require(path.resolve(CWD, 'package.json')); // eslint-disable-line
41
60
  const corePkg = core ? require(path.resolve(core, 'package.json')) : null; // eslint-disable-line
61
+ pkg = reactNative ? require(path.resolve(reactNativePath, 'package.json')) : pkg; // eslint-disable-line
42
62
  const { name, version, license, author } = pkg;
43
63
  const { sourcemap, replacementStrings = {}, typescript } = argv;
44
64
 
45
- if (corePkg) {
65
+ if (reactNative) {
66
+ dir = `${dir}/${reactNativePath}`;
67
+ } else if (corePkg) {
46
68
  pkg = corePkg;
47
69
  dir = core;
48
70
  }
@@ -72,6 +94,7 @@ const config = ({
72
94
 
73
95
  // stardust should always be external
74
96
  if (!peers['@nebula.js/stardust']) {
97
+ // eslint-disable-next-line no-console
75
98
  console.warn('@nebula.js/stardust should be specified as a peer dependency');
76
99
  } else if (external.indexOf('@nebula.js/stardust') === -1) {
77
100
  external.push('@nebula.js/stardust');
@@ -82,6 +105,7 @@ const config = ({
82
105
  input: path.resolve(CWD, 'src/index'),
83
106
  external,
84
107
  plugins: [
108
+ resolveNative({ reactNative }),
85
109
  replace({
86
110
  'process.env.NODE_ENV': JSON.stringify(mode === 'development' ? 'development' : 'production'),
87
111
  preventAssignment: true,
@@ -90,7 +114,9 @@ const config = ({
90
114
  nodeResolve({
91
115
  extensions,
92
116
  }),
93
- commonjs(),
117
+ commonjs({
118
+ ignoreTryCatch: false, // Avoids problems with require() inside try catch (https://github.com/rollup/plugins/issues/1004)
119
+ }),
94
120
  json(),
95
121
  babel({
96
122
  babelrc: false,
@@ -102,7 +128,7 @@ const config = ({
102
128
  {
103
129
  modules: false,
104
130
  targets: {
105
- browsers: ['ie 11', 'chrome 47'],
131
+ browsers: ['chrome 62'],
106
132
  },
107
133
  },
108
134
  ],
@@ -0,0 +1,28 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+ // this plugin will check if there is a corresponding .native file for the input file and output the contents of the native file
4
+ // This plugin should be loaded first.
5
+
6
+ module.exports = ({ carbon }) => ({
7
+ async load(id) {
8
+ if (!carbon) {
9
+ return null;
10
+ }
11
+ if (id) {
12
+ const parsed = path.parse(id);
13
+ if (parsed) {
14
+ if (parsed.name.length > 0) {
15
+ const nativeTest = `${parsed.dir}/${parsed.name}.native${parsed.ext}`;
16
+ try {
17
+ if (fs.existsSync(nativeTest)) {
18
+ return fs.readFileSync(nativeTest, { encoding: 'utf8', flag: 'r' });
19
+ }
20
+ } catch (err) {
21
+ console.log('there was a problem reading the file', nativeTest, err);
22
+ }
23
+ }
24
+ }
25
+ }
26
+ return null;
27
+ },
28
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebula.js/cli-build",
3
- "version": "2.1.0",
3
+ "version": "2.4.1",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "QlikTech International AB",
@@ -21,28 +21,28 @@
21
21
  "lint": "eslint src"
22
22
  },
23
23
  "dependencies": {
24
- "@babel/cli": "7.15.7",
25
- "@babel/core": "7.15.5",
26
- "@babel/plugin-transform-react-jsx": "7.14.9",
27
- "@babel/preset-env": "7.15.6",
28
- "@rollup/plugin-commonjs": "20.0.0",
24
+ "@babel/cli": "7.16.0",
25
+ "@babel/core": "7.16.0",
26
+ "@babel/plugin-transform-react-jsx": "7.16.0",
27
+ "@babel/preset-env": "7.16.4",
28
+ "@rollup/plugin-commonjs": "21.0.1",
29
29
  "@rollup/plugin-json": "4.1.0",
30
- "@rollup/plugin-node-resolve": "13.0.5",
30
+ "@rollup/plugin-node-resolve": "13.0.6",
31
31
  "@rollup/plugin-replace": "3.0.0",
32
- "@rollup/plugin-typescript": "8.2.5",
32
+ "@rollup/plugin-typescript": "8.3.0",
33
33
  "chalk": "4.1.2",
34
34
  "extend": "3.0.2",
35
- "postcss": "^8.3.8",
36
- "rollup": "2.57.0",
35
+ "postcss": "^8.4.4",
36
+ "rollup": "2.60.2",
37
37
  "rollup-plugin-babel": "4.4.0",
38
- "rollup-plugin-postcss": "4.0.1",
38
+ "rollup-plugin-postcss": "4.0.2",
39
39
  "rollup-plugin-sourcemaps": "0.6.3",
40
40
  "rollup-plugin-terser": "7.0.2",
41
- "yargs": "17.2.1"
41
+ "yargs": "17.3.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tslib": "*",
45
- "typescript": ">=3.7.0"
45
+ "typescript": ">=4.5.2"
46
46
  },
47
- "gitHead": "a8fa75cdd828e85879130a31ffc5c9f2a47fdfba"
47
+ "gitHead": "2e6fc2b046e7d2f8fb7bca6d035c5a5a7203bab0"
48
48
  }