Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Chu committed Sep 21, 2023
1 parent c4f9e9e commit 58e6487
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 120 deletions.
45 changes: 22 additions & 23 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
{
"name": "React SDK",

"image": "mcr.microsoft.com/devcontainers/javascript-node:1-18-bullseye",

"postCreateCommand": "npm install -g npm && yarn install",

"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"Gruntfuggly.todo-tree",
"github.vscode-github-actions",
"Orta.vscode-jest",
"ms-vscode.test-adapter-converter"
],
"settings": {
"files.eol": "\n"
}
}
}
"name": "React SDK",

"image": "mcr.microsoft.com/devcontainers/javascript-node:1-18-bullseye",

"postCreateCommand": "npm install -g npm && yarn install",

"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"Gruntfuggly.todo-tree",
"github.vscode-github-actions",
"Orta.vscode-jest",
"ms-vscode.test-adapter-converter"
],
"settings": {
"files.eol": "\n"
}
}
}
}
12 changes: 5 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"jest.autoRun": {
"onStartup": [
"all-tests"
]
},
"jest.jestCommandLine": "./node_modules/.bin/jest",
"jest.autoRevealOutput": "on-exec-error"
"jest.autoRun": {
"onStartup": ["all-tests"]
},
"jest.jestCommandLine": "./node_modules/.bin/jest",
"jest.autoRevealOutput": "on-exec-error"
}
41 changes: 21 additions & 20 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Copyright 2019, Optimizely
* Copyright 2019, 2023 Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -14,34 +14,35 @@
* limitations under the License.
*/

const fs = require("fs");
const path = require("path");
const execSync = require("child_process").execSync;
const path = require('path');
const execSync = require('child_process').execSync;

process.chdir(path.resolve(__dirname, ".."));
process.chdir(path.resolve(__dirname, '..'));

function exec(command, extraEnv) {
return execSync(command, {
stdio: "inherit",
env: Object.assign({}, process.env, extraEnv)
stdio: 'inherit',
env: Object.assign({}, process.env, extraEnv),
});
}

const packageName = 'react-sdk';
const umdName = 'optimizelyReactSdk'

console.log("\nBuilding ES modules...");
const umdName = 'optimizelyReactSdk';

console.log('\nBuilding ES modules...');
exec(`./node_modules/.bin/rollup -c scripts/config.js -f es -o dist/${packageName}.es.js`);

console.log("\nBuilding CommonJS modules...");

console.log('\nBuilding CommonJS modules...');
exec(`./node_modules/.bin/rollup -c scripts/config.js -f cjs -o dist/${packageName}.js`);

console.log("\nBuilding UMD modules...");

exec(`./node_modules/.bin/rollup -c scripts/config.js -f umd -o dist/${packageName}.umd.js --name ${umdName}`, {EXTERNALS: 'forBrowsers', BUILD_ENV: 'production' });

console.log("\nBuilding SystemJS modules...");

exec(`./node_modules/.bin/rollup -c scripts/config.js -f system -o dist/${packageName}.system.js`, {EXTERNALS: 'forBrowsers', BUILD_ENV: 'production' });
console.log('\nBuilding UMD modules...');
exec(`./node_modules/.bin/rollup -c scripts/config.js -f umd -o dist/${packageName}.umd.js --name ${umdName}`, {
EXTERNALS: 'forBrowsers',
BUILD_ENV: 'production',
});

console.log('\nBuilding SystemJS modules...');
exec(`./node_modules/.bin/rollup -c scripts/config.js -f system -o dist/${packageName}.system.js`, {
EXTERNALS: 'forBrowsers',
BUILD_ENV: 'production',
});
47 changes: 23 additions & 24 deletions scripts/config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Copyright 2019, Optimizely
* Copyright 2019, 2023 Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -14,23 +14,22 @@
* limitations under the License.
*/

const typescript = require('rollup-plugin-typescript2')
const commonjs = require('@rollup/plugin-commonjs')
const replace = require('@rollup/plugin-replace')
const { nodeResolve } = require('@rollup/plugin-node-resolve')
const { uglify } = require('rollup-plugin-uglify')
const typescript = require('rollup-plugin-typescript2');
const commonjs = require('@rollup/plugin-commonjs');
const replace = require('@rollup/plugin-replace');
const { nodeResolve } = require('@rollup/plugin-node-resolve');
const { uglify } = require('rollup-plugin-uglify');

const packageDeps = require('../package.json').dependencies || {}
const packagePeers = require('../package.json').peerDependencies || {}
const packageDeps = require('../package.json').dependencies || {};
const packagePeers = require('../package.json').peerDependencies || {};

function getExternals(externals) {
let externalLibs;
if(externals === 'forBrowsers') {
externalLibs = ['react']
if (externals === 'forBrowsers') {
externalLibs = ['react'];
} else {
externalLibs = (externals === 'peers')
? Object.keys(packagePeers)
: Object.keys(packageDeps).concat(Object.keys(packagePeers))
externalLibs =
externals === 'peers' ? Object.keys(packagePeers) : Object.keys(packageDeps).concat(Object.keys(packagePeers));
}
externalLibs.push('crypto');
return externalLibs;
Expand All @@ -40,40 +39,40 @@ function getPlugins(env, externals) {
const plugins = [
nodeResolve({
browser: externals === 'forBrowsers',
preferBuiltins: externals !== 'forBrowsers'
preferBuiltins: externals !== 'forBrowsers',
}),
commonjs({
include: /node_modules/,
}),
]
];

if (env) {
plugins.push(
replace({
'process.env.NODE_ENV': JSON.stringify(env),
}),
)
})
);
}

plugins.push(typescript())
plugins.push(typescript());

if (env === 'production') {
plugins.push(uglify())
plugins.push(uglify());
}

return plugins
return plugins;
}

const config = {
input: 'src/index.ts',
output: {
globals: {
react: 'React',
crypto: 'crypto'
crypto: 'crypto',
},
},
external: getExternals(process.env.EXTERNALS),
plugins: getPlugins(process.env.BUILD_ENV, process.env.EXTERNALS),
}
};

module.exports = config
module.exports = config;
97 changes: 51 additions & 46 deletions scripts/winbuild.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,51 @@
/**
* Copyright 2023, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

const fs = require("fs");
const path = require("path");
const execSync = require("child_process").execSync;

process.chdir(path.resolve(__dirname, ".."));

function exec(command, extraEnv) {
return execSync(command, {
stdio: "inherit",
env: Object.assign({}, process.env, extraEnv)
});
}

const packageName = 'react-sdk';
const umdName = 'optimizelyReactSdk'

console.log("\nBuilding ES modules...");
exec(`.\\node_modules\\.bin\\rollup -c scripts\\config.js -f es -o dist\\${packageName}.es.js`);

console.log("\nBuilding CommonJS modules...");

exec(`.\\node_modules\\.bin\\rollup -c scripts\\config.js -f cjs -o dist\\${packageName}.js`);

console.log("\nBuilding UMD modules...");

exec(`.\\node_modules\\.bin\\rollup -c scripts\\config.js -f umd -o dist\\${packageName}.umd.js --name ${umdName}`, {EXTERNALS: 'forBrowsers', BUILD_ENV: 'production' });

console.log("\nBuilding SystemJS modules...");

exec(`.\\node_modules\\.bin\\rollup -c scripts\\config.js -f system -o dist\\${packageName}.system.js`, {EXTERNALS: 'forBrowsers', BUILD_ENV: 'production' });
/**
* Copyright 2023, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

const path = require('path');
const execSync = require('child_process').execSync;

process.chdir(path.resolve(__dirname, '..'));

function exec(command, extraEnv) {
return execSync(command, {
stdio: 'inherit',
env: Object.assign({}, process.env, extraEnv),
});
}

const packageName = 'react-sdk';
const umdName = 'optimizelyReactSdk';

console.log('\nBuilding ES modules...');
exec(`.\\node_modules\\.bin\\rollup -c scripts\\config.js -f es -o dist\\${packageName}.es.js`);

console.log('\nBuilding CommonJS modules...');

exec(`.\\node_modules\\.bin\\rollup -c scripts\\config.js -f cjs -o dist\\${packageName}.js`);

console.log('\nBuilding UMD modules...');

exec(`.\\node_modules\\.bin\\rollup -c scripts\\config.js -f umd -o dist\\${packageName}.umd.js --name ${umdName}`, {
EXTERNALS: 'forBrowsers',
BUILD_ENV: 'production',
});

console.log('\nBuilding SystemJS modules...');

exec(`.\\node_modules\\.bin\\rollup -c scripts\\config.js -f system -o dist\\${packageName}.system.js`, {
EXTERNALS: 'forBrowsers',
BUILD_ENV: 'production',
});

0 comments on commit 58e6487

Please sign in to comment.