flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
40
BACK_BACK/node_modules/parcel-bundler/lib/assets/JSONAsset.js
generated
vendored
Executable file
40
BACK_BACK/node_modules/parcel-bundler/lib/assets/JSONAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
"use strict";
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const json5 = require('json5');
|
||||
|
||||
const _require = require('terser'),
|
||||
minify = _require.minify;
|
||||
|
||||
class JSONAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'js';
|
||||
}
|
||||
|
||||
parse(code) {
|
||||
return path.extname(this.name) === '.json5' ? json5.parse(code) : null;
|
||||
}
|
||||
|
||||
generate() {
|
||||
let code = `module.exports = ${this.ast ? JSON.stringify(this.ast, null, 2) : this.contents};`;
|
||||
|
||||
if (this.options.minify && !this.options.scopeHoist) {
|
||||
let minified = minify(code);
|
||||
|
||||
if (minified.error) {
|
||||
throw minified.error;
|
||||
}
|
||||
|
||||
code = minified.code;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = JSONAsset;
|
||||
Loading…
Add table
Add a link
Reference in a new issue