Skip to content

Commit

Permalink
feat: provide current ES targeted distributions
Browse files Browse the repository at this point in the history
plus dist.core is transformed again
  • Loading branch information
leeyeh committed Mar 26, 2020
1 parent 4c7b01c commit 57dc420
Show file tree
Hide file tree
Showing 11 changed files with 205 additions and 137 deletions.
1 change: 1 addition & 0 deletions es-latest/im.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../realtime';
1 change: 1 addition & 0 deletions es-latest/im.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../dist/es-latest/im');
1 change: 1 addition & 0 deletions es-latest/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../realtime';
1 change: 1 addition & 0 deletions es-latest/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../dist/es-latest/im-node');
89 changes: 73 additions & 16 deletions package-lock.json

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

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "5.0.0-rc.1",
"description": "LeanCloud Realtime Message JavaScript SDK",
"main": "./dist/im-node.js",
"jsnext:main": "./src/index.js",
"directories": {
"test": "test"
},
Expand All @@ -16,10 +15,10 @@
"test:browser": "if [ ! -z \"$SAUCE_ACCESS_KEY\" ]; then npm run build:test && karma start karma-sauce.conf.js; else echo 'Saucelabs test skipped, set SAUCE_USERNAME and SAUCE_ACCESS_KEY to start it.\n\rTo run browser tests locally, run `npm run test:browser-local`'; fi",
"test:browser-local": "npm run build:test && karma start",
"docs": "jsdoc src README.md package.json -d docs -c .jsdocrc.json && jsdoc plugins/typed-messages/src plugins/typed-messages/package.json src/messages/message.js src/messages/typed-message.js -d plugins/typed-messages/docs -c .jsdocrc.json && jsdoc plugins/webrtc/src plugins/webrtc/package.json -d plugins/webrtc/docs -c .jsdocrc.json && jsdoc plugins/groupchat-receipts/src plugins/groupchat-receipts/package.json -d plugins/groupchat-receipts/docs -c .jsdocrc.json",
"build": "npm run build:realtime && npm run build:plugins && ./script/validate-es5.js",
"build": "npm run build:realtime && BABEL_ENV=es5 npm run build:realtime && BABEL_ENV=es5 npm run build:plugins && ./script/validate-es5.js",
"build:realtime": "rollup -c rollup/rollup.config.realtime.js",
"build:plugins": "rollup -c rollup/rollup.config.plugins.js",
"build:test": "rollup -c rollup/rollup.config.test.js",
"build:test": "BABEL_ENV=es5 rollup -c rollup/rollup.config.test.js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"convert-pb": "pbjs proto/message.proto -t commonjs > proto/message-compiled.js && sed -i '' 's/protobufjs/protobufjs\\/dist\\/protobuf-light/g' ./proto/message-compiled.js"
},
Expand Down Expand Up @@ -74,7 +73,7 @@
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-uglify": "^6.0.3",
"rollup-plugin-terser": "^5.3.0",
"should": "^12.0.0",
"should-sinon": "^0.0.6",
"sinon": "^6.0.1",
Expand All @@ -98,11 +97,13 @@
},
"browser": {
"@leancloud/platform-adapters-node": "@leancloud/platform-adapters-browser",
"./dist/im-node.js": "./dist/im-browser.js"
"./dist/im-node.js": "./dist/im-browser.js",
"./dist/es-latest/im-node.js": "./dist/es-latest/im-browser.js"
},
"weapp": {
"@leancloud/platform-adapters-node": "@leancloud/platform-adapters-weapp",
"./dist/im-node.js": "./dist/im-weapp.js"
"./dist/im-node.js": "./dist/im-weapp.js",
"./dist/es-latest/im-node.js": "./dist/es-latest/im-weapp.js"
},
"nyc": {
"require": [
Expand Down
11 changes: 5 additions & 6 deletions rollup/rollup.config.plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import json from 'rollup-plugin-json';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';

import { withMinified, getBabelConfigs } from './shared-configs';
import { withMinified, babelConfig } from './shared-configs';

const createConfig = ({ input, output, id }) => ({
input,
Expand All @@ -29,11 +29,10 @@ const createConfig = ({ input, output, id }) => ({
},
plugins: [
json(),
babel(
Object.assign(getBabelConfigs(), {
exclude: 'node_modules/**',
})
),
babel({
...babelConfig,
exclude: 'node_modules/**',
}),
nodeResolve({
main: true,
}),
Expand Down
84 changes: 79 additions & 5 deletions rollup/rollup.config.realtime.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,96 @@
import { getNodeConfig, browser, weapp, withMinified } from './shared-configs';
import json from 'rollup-plugin-json';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import {
createRollupPluginsOptions,
babelConfig,
withMinified,
} from './shared-configs';

const INPUT_FILE = 'src/im-adapted.js';
const OUTPUT_DIR = process.env.BABEL_ENV === 'es5' ? 'dist' : 'dist/es-latest';

const node = {
input: INPUT_FILE,
output: {
file: `${OUTPUT_DIR}/im-node.js`,
format: 'cjs',
sourcemap: true,
},
plugins: [
json(),
babel({
...babelConfig,
exclude: 'node_modules/**',
}),
commonjs({
include: ['proto/**'],
}),
],
};

const node = getNodeConfig();
const core = {
...getNodeConfig(false),
...node,
input: 'src/core.js',
output: {
...node.output,
file: 'dist/core.js',
file: `${OUTPUT_DIR}/core.js`,
},
};

export const browser = {
input: INPUT_FILE,
output: {
file: `${OUTPUT_DIR}/im-browser.js`,
format: 'umd',
name: 'AV',
extend: true,
amd: {
id: 'leancloud-realtime',
},
sourcemap: true,
},
plugins: createRollupPluginsOptions({
browser: true,
}),
};

const im = {
...browser,
input: 'src/im.js',
output: {
...browser.output,
file: 'dist/im.js',
file: `${OUTPUT_DIR}/im.js`,
},
};

const weappRuntimeReset = () => ({
intro() {
return 'global.Object=Object;function Function(){return function(){}};';
},
});

export const weapp = {
input: INPUT_FILE,
output: {
file: `${OUTPUT_DIR}/im-weapp.js`,
format: 'umd',
name: 'AV',
extend: true,
amd: {
id: 'leancloud-realtime',
},
sourcemap: true,
},
plugins: [
...createRollupPluginsOptions({
browser: true,
customResolveOptions: {
aliasFields: ['weapp', 'browser'],
},
}),
weappRuntimeReset(),
],
};

export default [
Expand Down
2 changes: 1 addition & 1 deletion rollup/rollup.config.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash';
import replace from 'rollup-plugin-replace';
import { browser } from './shared-configs';
import { browser } from './rollup.config.realtime';

const envify = () =>
replace(
Expand Down
Loading

0 comments on commit 57dc420

Please sign in to comment.