Skip to content

Commit

Permalink
Merge branch 'release/v1.1.0'
Browse files Browse the repository at this point in the history
* release/v1.1.0:
  Add entry point that loads the right compiled library base on the running env
  Add serve package for samples run
  • Loading branch information
gfoiani committed Jul 13, 2021
2 parents 71e191b + 16d1542 commit 84b5501
Show file tree
Hide file tree
Showing 9 changed files with 341 additions and 18 deletions.
1 change: 1 addition & 0 deletions lib/index.js

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

8 changes: 8 additions & 0 deletions lib/indexNode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import AmqpClient from './protocols/amqpClient';
import AmqpStreamClient from './protocols/amqpStreamClient';
import MqttClient from './protocols/mqttClient';
import MqttStreamClient from './protocols/mqttStreamClient';
import StompClient from './protocols/stompClient';
import StompStreamClient from './protocols/stompStreamClient';
import { ISpaceBunnyParams } from './spacebunny';
export { AmqpClient as Client, AmqpClient, MqttClient, StompClient, AmqpStreamClient, AmqpStreamClient as StreamClient, MqttStreamClient, StompStreamClient, ISpaceBunnyParams };
10 changes: 5 additions & 5 deletions lib/spacebunny.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/spacebunny.js.map

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "spacebunny",
"version": "1.0.1",
"version": "1.1.0",
"description": "NodeJS client library for Space Bunny IoT platform",
"main": "lib/spacebunny.js",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"start:dev": "cross-env NODE_ENV=development nodemon --watch src",
Expand Down Expand Up @@ -71,6 +71,7 @@
"@typescript-eslint/eslint-plugin": "4.4.1",
"@typescript-eslint/parser": "4.4.1",
"axios-mock-adapter": "1.18.2",
"copy-webpack-plugin": "6.3.0",
"cross-env": "7.0.2",
"dotenv": "8.2.0",
"eslint": "7.11.0",
Expand All @@ -81,8 +82,10 @@
"faker": "5.1.0",
"husky": "4.3.0",
"jest": "26.5.3",
"ncp": "2.0.0",
"nodemon": "2.0.4",
"rimraf": "3.0.2",
"serve": "12.0.0",
"source-map-support": "0.5.19",
"string-replace-loader": "2.3.0",
"terser-webpack-plugin": "4.2.3",
Expand All @@ -94,6 +97,7 @@
"webpack-bundle-analyzer": "3.9.0",
"webpack-cli": "4.0.0",
"webpack-dev-server": "3.11.0",
"webpack-md5-hash": "0.0.6"
"webpack-md5-hash": "0.0.6",
"webpack-shell-plugin": "0.5.0"
}
}
12 changes: 12 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
// eslint-disable-next-line import/no-mutable-exports
let spacebunny;
if (typeof window === 'undefined') {
// running in node
spacebunny = require('./spacebunny');
} else {
// running in the browser
spacebunny = require('./spacebunny.var');
}

module.exports = spacebunny;
File renamed without changes.
18 changes: 17 additions & 1 deletion webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const path = require('path');
const webpack = require('webpack');
const WebpackMd5Hash = require('webpack-md5-hash');
const TerserPlugin = require('terser-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const WebpackShellPlugin = require('webpack-shell-plugin');
const minimist = require('minimist');
const _ = require('lodash');
const { resolve } = require('path');
Expand All @@ -14,6 +16,8 @@ const platform = (argv.platform) || process.platform;
const arch = (argv.arch) || process.arch;
const outputPath = path.join(__dirname, 'lib');

const copyTypesCommand = 'ncp ./lib/indexNode.d.ts ./lib/index.d.ts';

if (process.env.ANALYZER !== 'true') {
console.log(`\nCompile for ${platform}-${arch} in ${outputPath}\n`); // eslint-disable-line no-console
}
Expand All @@ -29,7 +33,7 @@ const baseConfig = {
modules: [__dirname, 'node_modules'],
extensions: ['.ts', '.tsx', '.js', '.json']
},
entry: { spacebunny: './src/index.ts' },
entry: { spacebunny: './src/indexNode.ts' },
target: 'node',
output: {
path: outputPath,
Expand Down Expand Up @@ -76,6 +80,18 @@ const baseConfig = {
noInfo: true, // set to false to see a list of every file being bundled.
options: {}
}),

new CopyWebpackPlugin({ patterns: [
{ from: './src/index.js', to: './index.js', toType: 'file' },
] }, { debug: false }),

new WebpackShellPlugin({
onBuildEnd: [
copyTypesCommand,
],
safe: true
}),

],
module: {
rules: [
Expand Down
Loading

0 comments on commit 84b5501

Please sign in to comment.