From 5094b2eec8822808f363e3298d9da224bde5f208 Mon Sep 17 00:00:00 2001 From: Jan Stuhlmann Date: Thu, 21 Jan 2021 11:19:08 +0100 Subject: [PATCH] use separate config for browser build --- README.md | 2 +- example/dist/index.js | 3 +-- example/index.js | 2 +- src/index.browser.ts | 7 +++++++ src/index.ts | 2 -- webpack.config.js | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) create mode 100755 src/index.browser.ts diff --git a/README.md b/README.md index ea439b67..b0c19085 100755 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Then in your HTML you use ### In Node.js ```js -const gridscale = require("@gridscale/api"); +const gridscale = require("@gridscale/api").gridscale; const client = new gridscale.Client("[API-Token]", "[User-UUID]"); ``` diff --git a/example/dist/index.js b/example/dist/index.js index f66f1125..30a4eb46 100644 --- a/example/dist/index.js +++ b/example/dist/index.js @@ -2,7 +2,7 @@ var process = require('process'); var colors = require('colors'); -var gridscale = require('@gridscale/api'); +var gridscale = require('@gridscale/api').gridscale; var client; @@ -13956,7 +13956,6 @@ exports.gridscale = gridscale; var api_1 = require("./api"); Object.defineProperty(exports, "GSError", { enumerable: true, get: function () { return api_1.GSError; } }); __exportStar(require("./Specs"), exports); -module.exports = gridscale; diff --git a/example/index.js b/example/index.js index 690e5bd3..d72cb984 100644 --- a/example/index.js +++ b/example/index.js @@ -1,7 +1,7 @@ var process = require('process'); var colors = require('colors'); -var gridscale = require('@gridscale/api'); +var gridscale = require('@gridscale/api').gridscale; var client; diff --git a/src/index.browser.ts b/src/index.browser.ts new file mode 100755 index 00000000..7e84e5c3 --- /dev/null +++ b/src/index.browser.ts @@ -0,0 +1,7 @@ +/** + * Export all publicly accessible modules + */ +import * as gridscale from './client'; + + +module.exports = gridscale; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index b8627779..2d6df0cb 100755 --- a/src/index.ts +++ b/src/index.ts @@ -6,5 +6,3 @@ import * as gridscale from './client'; export { ApiResult, ApiSettings, BaseObject, BaseRelationObject, GenericApiResult, GSError, Links, LogData, Meta, RequestOptions, RequestPollResult, VoidApiResult } from './api'; export { gridscale }; export * from './Specs'; - -module.exports = gridscale; \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 09ea7c79..c645b4a0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,7 +2,7 @@ const path = require('path'); module.exports = { context: path.resolve(__dirname, 'src'), - entry: './index.ts', + entry: './index.browser.ts', mode: 'production', module: { rules: [{