Skip to content

Add global export variable #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------------------
1.1.0
-------------------------------------------------------------------------------
* Add global variable name export for use in non-CommonJS environments
* Remove redundant lodash core dependency to reduce bundle bloat
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
1.0.0
-------------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ The SDK is available through [npm](https://npmjs.com/package/optimizely-client-s
npm install optimizely-client-sdk --save
```

Or to use in a non CommonJS fashion:

1. Pull in `dist/optimizely.min.js` as a `<script>`
2. Use as global variable `window.optimizelyClient`

###Using the SDK
See the Optimizely X Full Stack testing [developer documentation](http://developers.optimizely.com/server/reference/index.html) to learn how to set up your first JavaScript project and use the SDK.

Expand Down
8 changes: 4 additions & 4 deletions dist/optimizely.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var _ = require('lodash/core');
var _ = require('optimizely-server-sdk/node_modules/lodash/core');
var configValidator = require('optimizely-server-sdk/lib/utils/config_validator');
var defaultErrorHandler = require('optimizely-server-sdk/lib/plugins/error_handler');
var defaultEventDispatcher = require('./lib/plugins/event_dispatcher');
Expand All @@ -7,7 +7,7 @@ var logger = require('optimizely-server-sdk/lib/plugins/logger');

var Optimizely = require('optimizely-server-sdk/lib/optimizely');

var JAVASCRIPT_CLIENT_VERSION = '1.0.0';
var JAVASCRIPT_CLIENT_VERSION = '1.1.0';
var MODULE_NAME = 'INDEX';

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/event_dispatcher/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var _ = require('lodash/core');
var _ = require('optimizely-server-sdk/node_modules/lodash/core');
var es6Promise = require('es6-promise').Promise;

var POST_METHOD = 'POST';
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "optimizely-client-sdk",
"version": "1.0.0",
"description": "JavaScript SDK for client testing",
"version": "1.1.0",
"description": "JavaScript SDK for Optimizely X Full Stack",
"main": "index.js",
"scripts": {
"test": "./node_modules/.bin/mocha ./tests.js",
"build": "webpack index.js dist/optimizely.min.js",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest changing this to: "build": "webpack $npm_package_main dist/optimizely.min.js", so as to reduce the duplicate knowledge of the entrypoint. This way main is the canonical location for defining the entrypoint and the build script doesn't need tweaked if the entrypoint is moved.

"lint": "eslint lib/**"
},
"repository": {
Expand Down
10 changes: 2 additions & 8 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
var webpack = require('webpack');

module.exports = {
module: {
loaders: [
{ test: /\.json/, loader: 'json-loader' },
],
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
Expand All @@ -17,9 +12,8 @@ module.exports = {
}),
new webpack.optimize.DedupePlugin(),
],
entry: './index.js',
output: {
filename: 'optimizely.min.js',
path: './dist'
library: 'optimizelyClient',
libraryTarget: 'umd'
},
};