Skip to content

Commit

Permalink
Tools: Added webpack bundles.
Browse files Browse the repository at this point in the history
  • Loading branch information
bre1470 committed Jul 4, 2024
1 parent c663d76 commit d87e527
Show file tree
Hide file tree
Showing 7 changed files with 560 additions and 561 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.DS_Store

/.vscode/
/code/
/dist/
/lib/
/node_modules/
/tmp/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ The connectors are available as

* ES6 modules by importing `@highcharts/morningstar-connectors` in your project.

* UMD bundle by loading `@highcharts/morningstar-connectors/dist/all.js` in your
web app.
* UMD bundle by adding the `@highcharts/morningstar-connectors/dist/all.js`
script to your web app or web page.



Expand Down
927 changes: 373 additions & 554 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
"main": "lib/index.js",
"types": "lib/index.d.ts",
"devDependencies": {
"@highcharts/dashboards": "2.2.0",
"bundle-declarations-webpack-plugin": "^5.1.1",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"eslint": "^8.56.0",
"eslint-plugin-brackets": "^0.1.3",
Expand All @@ -33,7 +31,8 @@
"keywords": [
"Highcharts",
"Dashboards",
"Morningstar"
"Morningstar",
"Time Series"
],
"lint-staged": {
"*.ts": [
Expand All @@ -46,11 +45,12 @@
"scripts": {
"build": "tsc -p src/",
"prepare": "husky install",
"release": "npm pack",
"test": "npm run test:build",
"test:build": "npm run build",
"test:morningstar": "npx newman run tmp/Collection.json -e tmp/Environment.json",
"test:precommit": "npm run test",
"watch": "tsc -p src/ -w",
"webpack": "webpack"
"webpack": "npm run build && webpack"
}
}
2 changes: 1 addition & 1 deletion src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Morningstar Connector Sources
The source code of the Highcharts Dashboards connectors consist of the following
folders:

* [src/Shared/] - Shared implementations for autorization, common options, and
* [src/Shared/] - Shared implementations for authentication, common options, and
error handling.

* [src/TimeSeries/] - Connector implementation for the Morningstar TimeSeries
Expand Down
2 changes: 2 additions & 0 deletions src/Shared/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ that are shared across the different Morningstar connectors.
To-Dos
------

- [ ] Implement country-based default region.

- [ ] Implement `MorningstarConnector` with automated autorization.

- [ ] Implement `MorningstarConverter` with JSON processing and validation.
Expand Down
175 changes: 175 additions & 0 deletions webpack.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
/* *
*
* Imports
*
* */


import * as FS from 'node:fs';
import * as Path from 'node:path';


/* *
*
* Constants
*
* */


const namespace = 'MorningstarConnectors';
const projectFolder = FS.realpathSync(process.cwd());
const sourceFolder = './lib/';
const targetFolder = './dist/';


/* *
*
* Functions
*
* */


function addDashboardsUMDConfig(target, ...pathMembers) {
const amd = ['dashboards/dashboards']
const commonjs = ['@highcharts/dashboards'];
const root = ['Dashboards'];

if (pathMembers.length) {
amd.push(pathMembers[pathMembers.length - 1]);
commonjs.push(pathMembers[pathMembers.length - 1]);
root.push(pathMembers[pathMembers.length - 1]);
}

target[`@highcharts/dashboards/es-modules/${pathMembers.join('/')}`] = {
amd,
commonjs,
commonjs2: commonjs,
root
};

}


/* *
*
* Externals
*
* */


const externals = {};

addDashboardsUMDConfig(externals);
addDashboardsUMDConfig(externals, 'Data', 'Connectors', 'DataConnector');
addDashboardsUMDConfig(externals, 'Data', 'Converters', 'DataConverter');


/* *
*
* Distribution
*
* */


const webpacks = [
// Morningstar connectors
{
mode: 'production',

// path to the main file
entry: Path.resolve(projectFolder, `${sourceFolder}/index.js`),

externals,

// name for the javascript file that is created/compiled in memory
output: {
filename: 'morningstar-connectors.js',
globalObject: 'this',
library: {
name: namespace,
type: 'umd',
umdNamedDefine: true,
},
path: Path.resolve(projectFolder, targetFolder),
},

performance: {
hints: 'error',
maxAssetSize: 200000,
maxEntrypointSize: 200000,
},

resolve: {
extensions: ['.tsx', '.ts', '.js'],
},

},
// Morningstar Time Series
{
mode: 'production',

// path to the main file
entry: Path.resolve(projectFolder, `${sourceFolder}/TimeSeries/index.js`),

externals,

// name for the javascript file that is created/compiled in memory
output: {
filename: 'morningstar-time-series.js',
globalObject: 'this',
library: {
name: `${namespace}.TimeSeries`,
type: 'umd',
umdNamedDefine: true,
},
path: Path.resolve(projectFolder, targetFolder),
},

performance: {
hints: 'error',
maxAssetSize: 100000,
maxEntrypointSize: 100000,
},

resolve: {
extensions: ['.tsx', '.ts', '.js'],
},

}
];


/* *
*
* Highcharts Utils Code
*
* */


for (let webpack of webpacks.slice()) {
webpack = structuredClone(webpack);
webpack.optimization = {
...webpack.optimization,
minimize: false
};
webpack.output.filename =
Path.basename(webpack.output.filename, '.js') + '.src.js';
webpack.output.path =
Path.resolve(webpack.output.path, Path.join('..', 'code'));
webpack.performance = {
...webpack.performance,
maxAssetSize: 1000000,
maxEntrypointSize: 1000000,
};
webpacks.push(webpack);
}


/* *
*
* Default Export
*
* */


export default webpacks;

0 comments on commit d87e527

Please sign in to comment.