Skip to content

Commit a63b6b0

Browse files
committed
fix: seperate Node.js-only features from the core build
1 parent f080114 commit a63b6b0

File tree

9 files changed

+18
-18
lines changed

9 files changed

+18
-18
lines changed

core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('./dist/cjs/entry/core');
1+
module.exports = require('./dist/av-core');

live-query-core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('./dist/cjs/entry/core-live-query');
1+
module.exports = require('./dist/av-live-query-core');

live-query.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('./dist/cjs/entry/index-live-query');
1+
module.exports = require('./dist/node/entry/index-live-query');

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "leancloud-storage",
33
"version": "4.5.3",
4-
"main": "./dist/cjs/entry/index.js",
4+
"main": "./dist/node/entry/index.js",
55
"description": "LeanCloud JavaScript SDK.",
66
"repository": {
77
"type": "git",
@@ -14,12 +14,12 @@
1414
"test:node": "cross-env NODE_ENV=test nyc --reporter lcov --reporter text mocha --timeout 300000 test/index.js",
1515
"test:real": "cross-env REAL_BACKEND=1 npm run test:node",
1616
"docs": "jsdoc src README.md package.json -d docs -c .jsdocrc.json",
17-
"build:cjs": "babel src --out-dir dist/cjs",
17+
"build:node": "cross-env PLATFORM=NODE_JS babel src --out-dir dist/node",
1818
"build:core": "cross-env webpack --config webpack/core.js",
19-
"build:browser": "cross-env CLIENT_PLATFORM=Browser webpack --config webpack/browser.js",
20-
"build:weapp": "cross-env CLIENT_PLATFORM=Weapp webpack --config webpack/weapp.js",
19+
"build:browser": "cross-env PLATFORM=Browser webpack --config webpack/browser.js",
20+
"build:weapp": "cross-env PLATFORM=Weapp webpack --config webpack/weapp.js",
2121
"build:platforms": "npm run build:core && npm run build:browser && npm run build:weapp",
22-
"build": "rimraf dist && npm run build:cjs && npm run build:platforms && cross-env LIVE_QUERY=1 npm run build:platforms",
22+
"build": "rimraf dist && npm run build:node && npm run build:platforms && cross-env LIVE_QUERY=1 npm run build:platforms",
2323
"prepublishOnly": "./script/check-version.js"
2424
},
2525
"dependencies": {
@@ -76,14 +76,14 @@
7676
"@leancloud/platform-adapters-node": "@leancloud/platform-adapters-browser",
7777
"./src/utils/parse-base64.js": "./src/utils/parse-base64-browser.js",
7878
"./src/ua/comments.js": "./src/ua/comments-browser.js",
79-
"./dist/cjs/entry/index.js": "./dist/av-min.js"
79+
"./dist/node/entry/index.js": "./dist/av-min.js"
8080
},
8181
"react-native": {
82-
"./dist/cjs/entry/index.js": "./dist/av-rn-min.js"
82+
"./dist/node/entry/index.js": "./dist/av-core.js"
8383
},
8484
"weapp": {
8585
"@leancloud/platform-adapters-node": "@leancloud/platform-adapters-weapp",
86-
"./dist/cjs/entry/index.js": "./dist/av-weapp-min.js"
86+
"./dist/node/entry/index.js": "./dist/av-weapp-min.js"
8787
},
8888
"typings": "./storage.d.ts",
8989
"types": "./storage.d.ts",

src/captcha.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module.exports = AV => {
6060
);
6161
};
6262

63-
if (process.env.CLIENT_PLATFORM === 'Browser') {
63+
if (process.env.PLATFORM === 'Browser') {
6464
/**
6565
* Bind the captcha to HTMLElements. <b>ONLY AVAILABLE in browsers</b>.
6666
* @param [elements]

src/entry/use-adapters.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const adapters = require('@leancloud/platform-adapters-node');
22
const getUA = require('../ua');
3-
const comments = (process.env.CLIENT_PLATFORM
4-
? [process.env.CLIENT_PLATFORM]
3+
const comments = (process.env.PLATFORM === 'NODE_JS'
4+
? [process.env.PLATFORM]
55
: []
66
).concat(require('../ua/comments'));
77

src/init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ AV.init = function init(options, ...params) {
7878
);
7979
if (!appId) throw new TypeError('appId must be a string');
8080
if (!appKey) throw new TypeError('appKey must be a string');
81-
if (process.env.CLIENT_PLATFORM && masterKey)
81+
if (process.env.PLATFORM !== 'NODE_JS' && masterKey)
8282
console.warn('MasterKey is not supposed to be used at client side.');
8383
if (isCNApp(appId)) {
8484
if (!serverURLs && isEmpty(AV._config.serverURLs)) {
@@ -131,7 +131,7 @@ AV.init = function init(options, ...params) {
131131
};
132132

133133
// If we're running in node.js, allow using the master key.
134-
if (!process.env.CLIENT_PLATFORM) {
134+
if (process.env.PLATFORM === 'NODE_JS') {
135135
AV.Cloud = AV.Cloud || {};
136136
/**
137137
* Switches the LeanCloud SDK to using the Master key. The Master key grants

src/request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const setHeaders = (authOptions = {}, signKey) => {
5353
if (AV._config.production !== null) {
5454
headers['X-LC-Prod'] = String(AV._config.production);
5555
}
56-
headers[!process.env.CLIENT_PLATFORM ? 'User-Agent' : 'X-LC-UA'] =
56+
headers[process.env.PLATFORM === 'NODE_JS' ? 'User-Agent' : 'X-LC-UA'] =
5757
AV._sharedConfig.userAgent;
5858

5959
return Promise.resolve().then(() => {

webpack/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ exports.create = () => ({
5757
],
5858
},
5959
plugins: [
60-
new webpack.EnvironmentPlugin(['CLIENT_PLATFORM']),
60+
new webpack.EnvironmentPlugin(['PLATFORM']),
6161
new webpack.optimize.UglifyJsPlugin({
6262
include: /-min\.js$/,
6363
sourceMap: true,

0 commit comments

Comments
 (0)