Skip to content

Commit b5b8313

Browse files
Gcaufyleeyeh
authored andcommitted
chore(build): remove dead code in uncompress dist files
1 parent 49b9a12 commit b5b8313

File tree

4 files changed

+37
-21
lines changed

4 files changed

+37
-21
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
"should": "^11.1.0",
5757
"typescript": "^2.4.1",
5858
"weapp-polyfill": "^2.0.1",
59-
"webpack": "^2.2.0-rc.3"
59+
"webpack": "^2.2.0-rc.3",
60+
"webpack-strip-block": "^0.2.0"
6061
},
6162
"license": "MIT",
6263
"author": {

src/file.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ module.exports = function(AV) {
126126
this._extName = extname(data.name);
127127
}
128128
}
129-
130-
if (!process.env.CLIENT_PLATFORM) {
131-
if (data instanceof require('stream') && data.path) {
132-
this._extName = extname(data.path);
133-
}
134-
if (Buffer.isBuffer(data)) {
135-
this.attributes.metaData.size = data.length;
136-
}
129+
130+
/* NODE-ONLY:start */
131+
if (data instanceof require('stream') && data.path) {
132+
this._extName = extname(data.path);
133+
}
134+
if (Buffer.isBuffer(data)) {
135+
this.attributes.metaData.size = data.length;
137136
}
137+
/* NODE-ONLY:end */
138138

139139
let owner;
140140
if (data && data.owner) {
@@ -496,14 +496,14 @@ module.exports = function(AV) {
496496
if (typeof Blob !== "undefined" && data instanceof Blob) {
497497
return data;
498498
}
499-
if (!process.env.CLIENT_PLATFORM) {
500-
if (data instanceof require('stream')) {
501-
return data;
502-
}
503-
if (Buffer.isBuffer(data)) {
504-
return data;
505-
}
499+
/* NODE-ONLY:start */
500+
if (data instanceof require('stream')) {
501+
return data;
502+
}
503+
if (Buffer.isBuffer(data)) {
504+
return data;
506505
}
506+
/* NODE-ONLY:end */
507507
throw new TypeError('malformed file data');
508508
}).then(data => {
509509
switch (uploadInfo.provider) {

src/uploader/s3.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ module.exports = function upload(uploadInfo, data, file, saveOptions = {}) {
2929
reject(handleError(res.error, res));
3030
});
3131
req.on('error', (err, res) => reject(handleError(err, res)));
32-
if (!process.env.CLIENT_PLATFORM) {
33-
if (data instanceof require('stream')) {
34-
// data.pipe(req);
35-
throw new TypeError('Saving an AV.File from a Stream to S3 is not yet supported');
36-
}
32+
/* NODE-ONLY:start */
33+
if (data instanceof require('stream')) {
34+
// data.pipe(req);
35+
throw new TypeError('Saving an AV.File from a Stream to S3 is not yet supported');
3736
}
37+
/* NODE-ONLY:end */
3838
req.send(data).end();
3939
});
4040
};

webpack/common.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ exports.create = () => ({
3434
query: {
3535
presets: ['es2015'],
3636
},
37+
}, {
38+
test: /\.js$/,
39+
enforce: 'pre',
40+
include: [
41+
path.resolve(__dirname, '../src'),
42+
],
43+
use: [
44+
{
45+
loader: 'webpack-strip-block',
46+
options: {
47+
start: 'NODE-ONLY:start',
48+
end: 'NODE-ONLY:end',
49+
},
50+
},
51+
],
3752
},
3853
],
3954
},

0 commit comments

Comments
 (0)