Skip to content

Commit

Permalink
Merge pull request #199 from rdkcentral/dev
Browse files Browse the repository at this point in the history
Release v2.8.1
  • Loading branch information
michielvandergeest authored Aug 22, 2022
2 parents 6bacb49 + c32cb02 commit 727ffaf
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 15 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## v2.8.1

*22 aug 2022*

- Added browser build support
- Fixed issue related to ES5 polyfill path
- Fixed issue related to Dist with Monorepo setup
- Added Safari 12.0 as target for es6 configs in both rollup and esbuild bundlers

## v2.8.0

*21 jun 2022*
Expand Down
4 changes: 4 additions & 0 deletions docs/environmentvariables.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ You can use the following environment variables to customize the behavior of the
| `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`) |
| `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`) |
| `LNG_BUNDLER` | rollup | Specify which bundler the CLI should use to bundle the app. Possible values: `rollup`, `esbuild`. |
| `LNG_BROWSER_BUILD` | false | Specify whether or not browser build is to be generated. Possible values: `true`, `false`. |
| `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`. |
| `LNG_LIVE_RELOAD_PORT` | 8888 | Specifies the port Websocket is listening on. Live reload communication is driven by WebSockets. Possible values: Any numeric value. |


#### `LNG_SETTINGS_ENV`
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`.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Michiel van der Geest <[email protected]>",
"license": "Apache-2",
"name": "@lightningjs/cli",
"version": "2.8.0",
"version": "2.8.1",
"description": "Lightning-CLI: Command Line Interface tool for a seamless Lightning App Development flow",
"bin": {
"lightning": "./bin/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/configs/esbuild.es5.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module.exports = (folder, globalName) => {
entryPoints: [`${process.cwd()}/src/index.js`],
bundle: true,
target: 'es5',
mainFields: ['module', 'main', 'browser'],
mainFields: buildHelpers.getResolveConfigForBundlers(),
outfile: `${folder}/appBundle.es5.js`,
sourcemap,
format: 'iife',
Expand Down
15 changes: 13 additions & 2 deletions src/configs/esbuild.es6.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const os = require('os')
const alias = require('../plugins/esbuild-alias')
const babel = require('../helpers/esbuildbabel')
const babelPresetTypescript = require('@babel/preset-typescript')
const babelPresetEnv = require('@babel/preset-env')
const path = require('path')
const dotenv = require('dotenv')
const babelPluginClassProperties = require('@babel/plugin-proposal-class-properties')
Expand Down Expand Up @@ -67,7 +68,17 @@ module.exports = (folder, globalName) => {
]),
babel({
config: {
presets: [babelPresetTypescript],
presets: [
[
babelPresetEnv,
{
targets: {
safari: '12.0',
},
},
],
[babelPresetTypescript],
],
plugins: [babelPluginClassProperties, babelPluginInlineJsonImport],
},
}),
Expand All @@ -79,7 +90,7 @@ module.exports = (folder, globalName) => {
entryPoints: [`${process.cwd()}/src/index.js`],
bundle: true,
outfile: `${folder}/appBundle.js`,
mainFields: ['browser', 'module', 'main'],
mainFields: buildHelpers.getResolveConfigForBundlers(),
sourcemap,
format: 'iife',
define: defined,
Expand Down
2 changes: 1 addition & 1 deletion src/configs/rollup.es5.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ module.exports = {
'~': path.resolve(process.cwd(), 'node_modules/'),
},
}),
resolve({ extensions, mainFields: ['module', 'main', 'browser'] }),
resolve({ extensions, mainFields: buildHelpers.getResolveConfigForBundlers() }),
commonjs({ sourceMap: false }),
babel({
presets: [
Expand Down
15 changes: 13 additions & 2 deletions src/configs/rollup.es6.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const process = require('process')
const babel = require('@rollup/plugin-babel').babel
const babelPluginClassProperties = require('@babel/plugin-proposal-class-properties')
const babelPresetTypescript = require('@babel/preset-typescript')
const babelPresetEnv = require('@babel/preset-env')
const resolve = require('@rollup/plugin-node-resolve').nodeResolve
const commonjs = require('@rollup/plugin-commonjs')
const alias = require('@rollup/plugin-alias')
Expand Down Expand Up @@ -62,10 +63,20 @@ module.exports = {
'~': path.resolve(process.cwd(), 'node_modules/'),
},
}),
resolve({ extensions, mainFields: ['module', 'main', 'browser'] }),
resolve({ extensions, mainFields: buildHelpers.getResolveConfigForBundlers() }),
commonjs({ sourceMap: false }),
babel({
presets: [[babelPresetTypescript]],
presets: [
[
babelPresetEnv,
{
targets: {
safari: '12.0',
},
},
],
[babelPresetTypescript],
],
extensions,
babelHelpers: 'bundled',
plugins: [babelPluginClassProperties],
Expand Down
19 changes: 16 additions & 3 deletions src/helpers/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,12 @@ const bundlePolyfills = folder => {
spinner.start('Bundling ES5 polyfills and saving to "' + folder.split('/').pop() + '"')

const nodeModulesPath = hasNewSDK()
? path.join(process.cwd(), 'node_modules/@lightningjs/sdk')
: path.join(process.cwd(), 'node_modules/wpe-lightning-sdk/')
? 'node_modules/@lightningjs/sdk'
: 'node_modules/wpe-lightning-sdk'

const lightningSDKfolder = findFile(process.cwd(), nodeModulesPath)

const pathToPolyfills = path.join(nodeModulesPath, 'support/polyfills')
const pathToPolyfills = path.join(lightningSDKfolder, 'support/polyfills')

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

Expand Down Expand Up @@ -377,6 +379,16 @@ const ensureLightningApp = () => {
})
}

/**
* Function to get the config for node-resolve plugin
* @returns Object
*/
const getResolveConfigForBundlers = () => {
return process.env.LNG_BROWSER_BUILD === 'true'
? ['module', 'browser', 'main']
: ['module', 'main', 'browser']
}

const getSettingsFileName = () => {
let settingsFileName = 'settings.json'
if (process.env.LNG_SETTINGS_ENV) {
Expand Down Expand Up @@ -418,4 +430,5 @@ module.exports = {
ensureLightningApp,
getSettingsFileName,
findFile,
getResolveConfigForBundlers,
}
8 changes: 5 additions & 3 deletions src/helpers/dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ const replaceInFile = require('replace-in-file')
const buildHelpers = require('./build')

const setupDistFolder = (folder, type, metadata) => {
const nodeModulesPath = buildHelpers.hasNewSDK()
? path.join(process.cwd(), 'node_modules/@lightningjs/core')
: path.join(process.cwd(), 'node_modules/wpe-lightning/')
const corePath = buildHelpers.hasNewSDK()
? 'node_modules/@lightningjs/core'
: 'node_modules/wpe-lightning/'

const nodeModulesPath = buildHelpers.findFile(process.cwd(), corePath)

const settingsFileName = buildHelpers.getSettingsFileName()

Expand Down

0 comments on commit 727ffaf

Please sign in to comment.