From 6851605b900b4cbf9011e0f80179bcc43b70d9a8 Mon Sep 17 00:00:00 2001 From: sandeep-vedam Date: Fri, 1 Jul 2022 17:09:30 +0530 Subject: [PATCH 1/7] Added safari 12.0 as target for esbuild and rollup es6 config files --- src/configs/esbuild.es6.config.js | 13 ++++++++++++- src/configs/rollup.es6.config.js | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/configs/esbuild.es6.config.js b/src/configs/esbuild.es6.config.js index 7c4d1ed7..b68f41b4 100644 --- a/src/configs/esbuild.es6.config.js +++ b/src/configs/esbuild.es6.config.js @@ -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') @@ -67,7 +68,17 @@ module.exports = (folder, globalName) => { ]), babel({ config: { - presets: [babelPresetTypescript], + presets: [ + [ + babelPresetEnv, + { + targets: { + safari: '12.0', + }, + }, + ], + [babelPresetTypescript], + ], plugins: [babelPluginClassProperties, babelPluginInlineJsonImport], }, }), diff --git a/src/configs/rollup.es6.config.js b/src/configs/rollup.es6.config.js index fe294834..710cec5b 100644 --- a/src/configs/rollup.es6.config.js +++ b/src/configs/rollup.es6.config.js @@ -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') @@ -65,7 +66,17 @@ module.exports = { resolve({ extensions, mainFields: ['module', 'main', 'browser'] }), commonjs({ sourceMap: false }), babel({ - presets: [[babelPresetTypescript]], + presets: [ + [ + babelPresetEnv, + { + targets: { + safari: '12.0', + }, + }, + ], + [babelPresetTypescript], + ], extensions, babelHelpers: 'bundled', plugins: [babelPluginClassProperties], From c810e73c270d71a74c17aa05118bea4b98094ee6 Mon Sep 17 00:00:00 2001 From: Matthijs Date: Mon, 4 Jul 2022 13:59:23 +0200 Subject: [PATCH 2/7] Fix es5 polyfill path --- src/helpers/build.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/helpers/build.js b/src/helpers/build.js index b718fbc1..7db3006e 100644 --- a/src/helpers/build.js +++ b/src/helpers/build.js @@ -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)) From 33983349d07c1825a4b06f270dd421a59ce5f95f Mon Sep 17 00:00:00 2001 From: Matthijs Date: Mon, 4 Jul 2022 14:46:03 +0200 Subject: [PATCH 3/7] Fix dist with monorepo setup --- src/helpers/dist.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/helpers/dist.js b/src/helpers/dist.js index 84fad0e6..8b90948f 100644 --- a/src/helpers/dist.js +++ b/src/helpers/dist.js @@ -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() From f4a1d79d2e393e5cca3e3b9dcb99f66ad53899a0 Mon Sep 17 00:00:00 2001 From: sandeep-vedam Date: Tue, 5 Jul 2022 18:42:33 +0530 Subject: [PATCH 4/7] Added support for browser build support and used PR130 for these changes --- docs/environmentvariables.md | 2 ++ src/configs/esbuild.es5.config.js | 2 +- src/configs/esbuild.es6.config.js | 2 +- src/configs/rollup.es5.config.js | 2 +- src/configs/rollup.es6.config.js | 2 +- src/helpers/build.js | 11 +++++++++++ 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/docs/environmentvariables.md b/docs/environmentvariables.md index 08172082..a4818010 100644 --- a/docs/environmentvariables.md +++ b/docs/environmentvariables.md @@ -49,6 +49,8 @@ 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_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`. diff --git a/src/configs/esbuild.es5.config.js b/src/configs/esbuild.es5.config.js index 162fbde9..735db58c 100644 --- a/src/configs/esbuild.es5.config.js +++ b/src/configs/esbuild.es5.config.js @@ -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', diff --git a/src/configs/esbuild.es6.config.js b/src/configs/esbuild.es6.config.js index 7c4d1ed7..e6580996 100644 --- a/src/configs/esbuild.es6.config.js +++ b/src/configs/esbuild.es6.config.js @@ -79,7 +79,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, diff --git a/src/configs/rollup.es5.config.js b/src/configs/rollup.es5.config.js index d0a2ac19..d7700db9 100644 --- a/src/configs/rollup.es5.config.js +++ b/src/configs/rollup.es5.config.js @@ -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: [ diff --git a/src/configs/rollup.es6.config.js b/src/configs/rollup.es6.config.js index fe294834..6d5d4938 100644 --- a/src/configs/rollup.es6.config.js +++ b/src/configs/rollup.es6.config.js @@ -62,7 +62,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: [[babelPresetTypescript]], diff --git a/src/helpers/build.js b/src/helpers/build.js index b718fbc1..9be87147 100644 --- a/src/helpers/build.js +++ b/src/helpers/build.js @@ -377,6 +377,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) { @@ -418,4 +428,5 @@ module.exports = { ensureLightningApp, getSettingsFileName, findFile, + getResolveConfigForBundlers, } From 657a97f63d476e41bd149605eec8b0465744c621 Mon Sep 17 00:00:00 2001 From: sandeep-vedam Date: Thu, 28 Jul 2022 16:56:33 +0530 Subject: [PATCH 5/7] Bumped version to 2.8.1 and added changelog --- CHANGELOG.md | 9 +++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c6e41e4..f0732e2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## v2.8.1 + +*28 jul 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* diff --git a/package-lock.json b/package-lock.json index 3e3fa47a..46b190f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lightningjs/cli", - "version": "2.8.0", + "version": "2.8.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@lightningjs/cli", - "version": "2.8.0", + "version": "2.8.1", "license": "Apache-2", "dependencies": { "@babel/core": "^7.11.6", diff --git a/package.json b/package.json index 4e4fffa4..741a7f0a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Michiel van der Geest ", "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", From f46c778ec0889f9488b90ad0ed276e16a583cbce Mon Sep 17 00:00:00 2001 From: sandeep-vedam Date: Tue, 16 Aug 2022 13:00:12 +0530 Subject: [PATCH 6/7] Added live reload and live reload port in the environmental variable documentation --- docs/environmentvariables.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/environmentvariables.md b/docs/environmentvariables.md index a4818010..c0584af9 100644 --- a/docs/environmentvariables.md +++ b/docs/environmentvariables.md @@ -50,6 +50,8 @@ You can use the following environment variables to customize the behavior of the | `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` From 1cbd185d64de7024c204e63feb030470abdacd99 Mon Sep 17 00:00:00 2001 From: Michiel van der Geest Date: Mon, 22 Aug 2022 11:50:17 +0200 Subject: [PATCH 7/7] Changed date on changelog. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0732e2a..56a724c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## v2.8.1 -*28 jul 2022* +*22 aug 2022* - Added browser build support - Fixed issue related to ES5 polyfill path