Merge pull request #1348 from 0xProject/feature/instant/cdn-setup
[instant] Remove commonjs bundle, productionize UMD bundle
This commit is contained in:
commit
f496096ce1
@ -1,6 +1,6 @@
|
||||
{
|
||||
"domain": "0x-instant-dogfood",
|
||||
"build_command": "WEBPACK_OUTPUT_PATH=public yarn build:umd:prod",
|
||||
"build_command": "WEBPACK_OUTPUT_PATH=public yarn build",
|
||||
"upload_directory": "public",
|
||||
"index_key": "index.html",
|
||||
"error_key": "index.html",
|
||||
|
13
packages/instant/.production.discharge.json
Normal file
13
packages/instant/.production.discharge.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"domain": "instant.0xproject.com",
|
||||
"build_command": "yarn build",
|
||||
"upload_directory": "umd",
|
||||
"index_key": "instant.js",
|
||||
"error_key": "404.html",
|
||||
"trailing_slashes": true,
|
||||
"cache": 3600,
|
||||
"aws_profile": "default",
|
||||
"aws_region": "us-east-1",
|
||||
"cdn": true,
|
||||
"dns_configured": true
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"domain": "0x-instant-staging",
|
||||
"build_command": "WEBPACK_OUTPUT_PATH=public yarn build:umd:prod",
|
||||
"build_command": "WEBPACK_OUTPUT_PATH=public yarn build",
|
||||
"upload_directory": "public",
|
||||
"index_key": "index.html",
|
||||
"error_key": "index.html",
|
||||
|
@ -2,39 +2,11 @@
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
yarn add @0x/instant
|
||||
```
|
||||
|
||||
**Import**
|
||||
|
||||
**CommonJS module**
|
||||
|
||||
```typescript
|
||||
import { ZeroExInstant } from '@0x/instant';
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```javascript
|
||||
var ZeroExInstant = require('@0x/instant').ZeroExInstant;
|
||||
```
|
||||
|
||||
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
|
||||
|
||||
```json
|
||||
"compilerOptions": {
|
||||
"typeRoots": ["node_modules/@0x/typescript-typings/types", "node_modules/@types"],
|
||||
}
|
||||
```
|
||||
|
||||
**UMD Module**
|
||||
|
||||
The package is also available as a UMD module named `zeroExInstant`.
|
||||
The package is available as a UMD module named `zeroExInstant` at https://instant.0xproject.com/instant.js.
|
||||
|
||||
```html
|
||||
<head>
|
||||
<script type="text/javascript" src="[zeroExInstantUMDPath]" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="https://instant.0xproject.com/instant.js" charset="utf-8"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="zeroExInstantContainer"></div>
|
||||
@ -48,23 +20,31 @@ The package is also available as a UMD module named `zeroExInstant`.
|
||||
|
||||
## Deploying
|
||||
|
||||
You can deploy a work-in-progress version of 0x Instant at http://0x-instant-dogfood.s3-website-us-east-1.amazonaws.com for easy sharing.
|
||||
You can deploy a work-in-progress version of 0x Instant at http://0x-instant-dogfood.s3-website-us-east-1.amazonaws.com/instant.js for easy sharing.
|
||||
|
||||
To build and deploy the site run
|
||||
To build and deploy the bundle run
|
||||
|
||||
```
|
||||
yarn deploy_dogfood
|
||||
```
|
||||
|
||||
We also have a staging bucket that is to be updated less frequently can be used to share instant externally: http://0x-instant-staging.s3-website-us-east-1.amazonaws.com/
|
||||
We also have a staging bucket that is to be updated less frequently can be used to share a beta version of instant externally: http://0x-instant-staging.s3-website-us-east-1.amazonaws.com/instant.js
|
||||
|
||||
To build and deploy to this bucket, run
|
||||
To build and deploy to this bundle, run
|
||||
|
||||
```
|
||||
yarn deploy_staging
|
||||
```
|
||||
|
||||
**NOTE: On deploying the site, it will say the site is available at a non-existent URL. Please ignore and use the (now updated) URL above.**
|
||||
Finally, we have our live production bundle that is only meant to be updated with stable, polished releases: https://instant.0xproject.com/instant.js
|
||||
|
||||
To build and deploy to this bundle, run
|
||||
|
||||
```
|
||||
yarn deploy_production
|
||||
```
|
||||
|
||||
**NOTE: On deploying the site to staging and dogfood, it will say the site is available at a non-existent URL. Please ignore and use the (now updated) URL above.**
|
||||
|
||||
## Contributing
|
||||
|
||||
|
@ -6,15 +6,11 @@
|
||||
},
|
||||
"private": true,
|
||||
"description": "0x Instant React Component",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"main": "umd/instant.js",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "yarn build:all",
|
||||
"build:all": "run-p build:umd:prod build:commonjs",
|
||||
"build:umd:prod": "webpack --mode production",
|
||||
"build:commonjs": "tsc -b",
|
||||
"build": "webpack --mode production",
|
||||
"build:ci": "yarn build",
|
||||
"watch_without_deps": "tsc -w",
|
||||
"dev": "webpack-dev-server --mode development",
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"test": "jest",
|
||||
@ -24,6 +20,7 @@
|
||||
"clean": "shx rm -rf lib coverage scripts",
|
||||
"deploy_dogfood": "discharge deploy -c .dogfood.discharge.json",
|
||||
"deploy_staging": "discharge deploy -c .staging.discharge.json",
|
||||
"deploy_production": "discharge deploy -c .production.discharge.json",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
||||
},
|
||||
"config": {
|
||||
@ -99,6 +96,6 @@
|
||||
"webpack-dev-server": "^3.1.9"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
"access": "private"
|
||||
}
|
||||
}
|
||||
|
@ -110,3 +110,7 @@ export const render = (config: ZeroExInstantConfig, selector: string = DEFAULT_Z
|
||||
};
|
||||
window.onpopstate = onPopStateHandler;
|
||||
};
|
||||
|
||||
// Write version info to the exported object for debugging
|
||||
export const GIT_SHA = process.env.GIT_SHA;
|
||||
export const NPM_VERSION = process.env.NPM_PACKAGE_VERSION;
|
||||
|
@ -5,8 +5,10 @@
|
||||
"rootDir": "src",
|
||||
"jsx": "react",
|
||||
"noImplicitAny": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"declaration": false,
|
||||
"declarationMap": false,
|
||||
"composite": false
|
||||
},
|
||||
"include": ["./src/**/*"],
|
||||
"exclude": ["./src/index.umd.ts"]
|
||||
"include": ["./src/**/*"]
|
||||
}
|
||||
|
@ -3,9 +3,6 @@ const ip = require('ip');
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
|
||||
// The common js bundle (not this one) is built using tsc.
|
||||
// The umd bundle (this one) has a different entrypoint.
|
||||
|
||||
const GIT_SHA = childProcess
|
||||
.execSync('git rev-parse HEAD')
|
||||
.toString()
|
||||
|
@ -34,7 +34,6 @@
|
||||
{ "path": "./packages/dev-utils" },
|
||||
{ "path": "./packages/ethereum-types" },
|
||||
{ "path": "./packages/fill-scenarios" },
|
||||
{ "path": "./packages/instant" },
|
||||
{ "path": "./packages/json-schemas" },
|
||||
{ "path": "./packages/metacoin" },
|
||||
{ "path": "./packages/migrations" },
|
||||
@ -57,5 +56,8 @@
|
||||
// Skipping website because it requires allowJs: false and this is
|
||||
// incompatible with project references.
|
||||
// { "path": "./packages/website" }
|
||||
// Skipping instant because it only produces a UMD bundle
|
||||
// which it uses webpack to create
|
||||
// { "path": "./packages/instant" },
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user