Skip to content

Commit 727ffaf

Browse files
Merge pull request #199 from rdkcentral/dev
Release v2.8.1
2 parents 6bacb49 + c32cb02 commit 727ffaf

File tree

10 files changed

+65
-15
lines changed

10 files changed

+65
-15
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## v2.8.1
4+
5+
*22 aug 2022*
6+
7+
- Added browser build support
8+
- Fixed issue related to ES5 polyfill path
9+
- Fixed issue related to Dist with Monorepo setup
10+
- Added Safari 12.0 as target for es6 configs in both rollup and esbuild bundlers
11+
312
## v2.8.0
413

514
*21 jun 2022*

docs/environmentvariables.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ You can use the following environment variables to customize the behavior of the
4949
| `LNG_BUILD_EXIT_ON_FAIL` | false | Specifies whether or not the build process should hard exit when a build error occurs. Note that the build process is triggered in several commands (`lng build`, `lng dev`, `lng watch` and `lng dist`) |
5050
| `LNG_BUILD_FAIL_ON_WARNINGS` | false | Specifies whether or not to show the warning to the user when a build warning occurs. Note that the build process is triggered in several commands (`lng build`, `lng dev`, `lng watch` and `lng dist`) |
5151
| `LNG_BUNDLER` | rollup | Specify which bundler the CLI should use to bundle the app. Possible values: `rollup`, `esbuild`. |
52+
| `LNG_BROWSER_BUILD` | false | Specify whether or not browser build is to be generated. Possible values: `true`, `false`. |
53+
| `LNG_LIVE_RELOAD` | false | Instructs your browser to reload the location when a new app bundle is created (using `lng dev`). When the watcher resolves, `document.location.reload()` is called in the browser (tab) that serves your app. Possible value:  `true`, `false`. |
54+
| `LNG_LIVE_RELOAD_PORT` | 8888 | Specifies the port Websocket is listening on. Live reload communication is driven by WebSockets. Possible values: Any numeric value. |
55+
5256

5357
#### `LNG_SETTINGS_ENV`
5458
Specifies which environment to be used. User need to have `settings.{env}.json` file in the Project home folder with different settings. This will build/dist the application with `settings.{env}.json`.

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Michiel van der Geest <[email protected]>",
33
"license": "Apache-2",
44
"name": "@lightningjs/cli",
5-
"version": "2.8.0",
5+
"version": "2.8.1",
66
"description": "Lightning-CLI: Command Line Interface tool for a seamless Lightning App Development flow",
77
"bin": {
88
"lightning": "./bin/index.js",

src/configs/esbuild.es5.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ module.exports = (folder, globalName) => {
100100
entryPoints: [`${process.cwd()}/src/index.js`],
101101
bundle: true,
102102
target: 'es5',
103-
mainFields: ['module', 'main', 'browser'],
103+
mainFields: buildHelpers.getResolveConfigForBundlers(),
104104
outfile: `${folder}/appBundle.es5.js`,
105105
sourcemap,
106106
format: 'iife',

src/configs/esbuild.es6.config.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const os = require('os')
2222
const alias = require('../plugins/esbuild-alias')
2323
const babel = require('../helpers/esbuildbabel')
2424
const babelPresetTypescript = require('@babel/preset-typescript')
25+
const babelPresetEnv = require('@babel/preset-env')
2526
const path = require('path')
2627
const dotenv = require('dotenv')
2728
const babelPluginClassProperties = require('@babel/plugin-proposal-class-properties')
@@ -67,7 +68,17 @@ module.exports = (folder, globalName) => {
6768
]),
6869
babel({
6970
config: {
70-
presets: [babelPresetTypescript],
71+
presets: [
72+
[
73+
babelPresetEnv,
74+
{
75+
targets: {
76+
safari: '12.0',
77+
},
78+
},
79+
],
80+
[babelPresetTypescript],
81+
],
7182
plugins: [babelPluginClassProperties, babelPluginInlineJsonImport],
7283
},
7384
}),
@@ -79,7 +90,7 @@ module.exports = (folder, globalName) => {
7990
entryPoints: [`${process.cwd()}/src/index.js`],
8091
bundle: true,
8192
outfile: `${folder}/appBundle.js`,
82-
mainFields: ['browser', 'module', 'main'],
93+
mainFields: buildHelpers.getResolveConfigForBundlers(),
8394
sourcemap,
8495
format: 'iife',
8596
define: defined,

src/configs/rollup.es5.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module.exports = {
6565
'~': path.resolve(process.cwd(), 'node_modules/'),
6666
},
6767
}),
68-
resolve({ extensions, mainFields: ['module', 'main', 'browser'] }),
68+
resolve({ extensions, mainFields: buildHelpers.getResolveConfigForBundlers() }),
6969
commonjs({ sourceMap: false }),
7070
babel({
7171
presets: [

src/configs/rollup.es6.config.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const process = require('process')
2222
const babel = require('@rollup/plugin-babel').babel
2323
const babelPluginClassProperties = require('@babel/plugin-proposal-class-properties')
2424
const babelPresetTypescript = require('@babel/preset-typescript')
25+
const babelPresetEnv = require('@babel/preset-env')
2526
const resolve = require('@rollup/plugin-node-resolve').nodeResolve
2627
const commonjs = require('@rollup/plugin-commonjs')
2728
const alias = require('@rollup/plugin-alias')
@@ -62,10 +63,20 @@ module.exports = {
6263
'~': path.resolve(process.cwd(), 'node_modules/'),
6364
},
6465
}),
65-
resolve({ extensions, mainFields: ['module', 'main', 'browser'] }),
66+
resolve({ extensions, mainFields: buildHelpers.getResolveConfigForBundlers() }),
6667
commonjs({ sourceMap: false }),
6768
babel({
68-
presets: [[babelPresetTypescript]],
69+
presets: [
70+
[
71+
babelPresetEnv,
72+
{
73+
targets: {
74+
safari: '12.0',
75+
},
76+
},
77+
],
78+
[babelPresetTypescript],
79+
],
6980
extensions,
7081
babelHelpers: 'bundled',
7182
plugins: [babelPluginClassProperties],

src/helpers/build.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,12 @@ const bundlePolyfills = folder => {
238238
spinner.start('Bundling ES5 polyfills and saving to "' + folder.split('/').pop() + '"')
239239

240240
const nodeModulesPath = hasNewSDK()
241-
? path.join(process.cwd(), 'node_modules/@lightningjs/sdk')
242-
: path.join(process.cwd(), 'node_modules/wpe-lightning-sdk/')
241+
? 'node_modules/@lightningjs/sdk'
242+
: 'node_modules/wpe-lightning-sdk'
243+
244+
const lightningSDKfolder = findFile(process.cwd(), nodeModulesPath)
243245

244-
const pathToPolyfills = path.join(nodeModulesPath, 'support/polyfills')
246+
const pathToPolyfills = path.join(lightningSDKfolder, 'support/polyfills')
245247

246248
const polyfills = fs.readdirSync(pathToPolyfills).map(file => path.join(pathToPolyfills, file))
247249

@@ -377,6 +379,16 @@ const ensureLightningApp = () => {
377379
})
378380
}
379381

382+
/**
383+
* Function to get the config for node-resolve plugin
384+
* @returns Object
385+
*/
386+
const getResolveConfigForBundlers = () => {
387+
return process.env.LNG_BROWSER_BUILD === 'true'
388+
? ['module', 'browser', 'main']
389+
: ['module', 'main', 'browser']
390+
}
391+
380392
const getSettingsFileName = () => {
381393
let settingsFileName = 'settings.json'
382394
if (process.env.LNG_SETTINGS_ENV) {
@@ -418,4 +430,5 @@ module.exports = {
418430
ensureLightningApp,
419431
getSettingsFileName,
420432
findFile,
433+
getResolveConfigForBundlers,
421434
}

src/helpers/dist.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ const replaceInFile = require('replace-in-file')
2424
const buildHelpers = require('./build')
2525

2626
const setupDistFolder = (folder, type, metadata) => {
27-
const nodeModulesPath = buildHelpers.hasNewSDK()
28-
? path.join(process.cwd(), 'node_modules/@lightningjs/core')
29-
: path.join(process.cwd(), 'node_modules/wpe-lightning/')
27+
const corePath = buildHelpers.hasNewSDK()
28+
? 'node_modules/@lightningjs/core'
29+
: 'node_modules/wpe-lightning/'
30+
31+
const nodeModulesPath = buildHelpers.findFile(process.cwd(), corePath)
3032

3133
const settingsFileName = buildHelpers.getSettingsFileName()
3234

0 commit comments

Comments
 (0)