@kosatyi/ejs 0.0.86 → 0.0.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/bundler.js +0 -1
- package/dist/cjs/bundler.js +9 -31
- package/dist/esm/bundler.js +9 -31
- package/package.json +5 -7
package/bin/bundler.js
CHANGED
package/dist/cjs/bundler.js
CHANGED
|
@@ -4,7 +4,6 @@ var fs = require('fs');
|
|
|
4
4
|
var glob = require('glob');
|
|
5
5
|
var watch = require('glob-watcher');
|
|
6
6
|
var path = require('path');
|
|
7
|
-
var terser = require('terser');
|
|
8
7
|
var index_js = require('./index.js');
|
|
9
8
|
|
|
10
9
|
const isPlainObject = function(obj) {
|
|
@@ -45,9 +44,9 @@ class Bundler {
|
|
|
45
44
|
return index_js.compile(content, name).source
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
|
|
47
|
+
getBundle() {
|
|
49
48
|
const umd = this.options.umd;
|
|
50
|
-
const
|
|
49
|
+
const strict = this.config.withObject === false;
|
|
51
50
|
const module = this.config.export;
|
|
52
51
|
const out = [];
|
|
53
52
|
if (umd) {
|
|
@@ -59,35 +58,18 @@ class Bundler {
|
|
|
59
58
|
out.push(`global || self,global["${module}"] = factory())`);
|
|
60
59
|
out.push('})(this,(function(){');
|
|
61
60
|
}
|
|
62
|
-
out.push(
|
|
63
|
-
if (umd) {
|
|
64
|
-
out.push('return templates}))');
|
|
65
|
-
} else {
|
|
66
|
-
out.push('export default templates');
|
|
67
|
-
}
|
|
68
|
-
return out.join(minify ? '' : '\n')
|
|
69
|
-
}
|
|
70
|
-
async stageMinify(content) {
|
|
71
|
-
if (this.options.minify === false) return content
|
|
72
|
-
const config = {
|
|
73
|
-
compress: {
|
|
74
|
-
dead_code: false,
|
|
75
|
-
side_effects: false
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
const response = await terser.minify(content, config);
|
|
79
|
-
return response.code
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
getBundle() {
|
|
83
|
-
const out = [];
|
|
84
|
-
if (this.config.withObject === false) out.push(`'use strict'`);
|
|
61
|
+
if (strict) out.push(`'use strict'`);
|
|
85
62
|
out.push('const templates = {}');
|
|
86
63
|
Object.entries(this.templates).forEach(([name, content]) => {
|
|
87
64
|
name = JSON.stringify(name);
|
|
88
65
|
content = String(content);
|
|
89
66
|
out.push(`templates[${name}] = ${content}`);
|
|
90
67
|
});
|
|
68
|
+
if (umd) {
|
|
69
|
+
out.push('return templates}))');
|
|
70
|
+
} else {
|
|
71
|
+
out.push('export default templates');
|
|
72
|
+
}
|
|
91
73
|
return out.join('\n')
|
|
92
74
|
}
|
|
93
75
|
async watch() {
|
|
@@ -133,11 +115,7 @@ class Bundler {
|
|
|
133
115
|
|
|
134
116
|
async output() {
|
|
135
117
|
const target = [].concat(this.options.target);
|
|
136
|
-
|
|
137
|
-
if (this.options.minify) {
|
|
138
|
-
content = await this.stageMinify(content);
|
|
139
|
-
}
|
|
140
|
-
content = this.stageWrapper(content);
|
|
118
|
+
const content = this.getBundle();
|
|
141
119
|
for (let file of target) {
|
|
142
120
|
const folderPath = path.dirname(file);
|
|
143
121
|
const folderExists = await fs.promises
|
package/dist/esm/bundler.js
CHANGED
|
@@ -2,7 +2,6 @@ import { promises } from 'fs';
|
|
|
2
2
|
import { glob } from 'glob';
|
|
3
3
|
import watch from 'glob-watcher';
|
|
4
4
|
import { join, dirname } from 'path';
|
|
5
|
-
import { minify } from 'terser';
|
|
6
5
|
import { configure, compile } from './index.js';
|
|
7
6
|
|
|
8
7
|
const isPlainObject = function(obj) {
|
|
@@ -43,9 +42,9 @@ class Bundler {
|
|
|
43
42
|
return compile(content, name).source
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
getBundle() {
|
|
47
46
|
const umd = this.options.umd;
|
|
48
|
-
const
|
|
47
|
+
const strict = this.config.withObject === false;
|
|
49
48
|
const module = this.config.export;
|
|
50
49
|
const out = [];
|
|
51
50
|
if (umd) {
|
|
@@ -57,35 +56,18 @@ class Bundler {
|
|
|
57
56
|
out.push(`global || self,global["${module}"] = factory())`);
|
|
58
57
|
out.push('})(this,(function(){');
|
|
59
58
|
}
|
|
60
|
-
out.push(
|
|
61
|
-
if (umd) {
|
|
62
|
-
out.push('return templates}))');
|
|
63
|
-
} else {
|
|
64
|
-
out.push('export default templates');
|
|
65
|
-
}
|
|
66
|
-
return out.join(minify ? '' : '\n')
|
|
67
|
-
}
|
|
68
|
-
async stageMinify(content) {
|
|
69
|
-
if (this.options.minify === false) return content
|
|
70
|
-
const config = {
|
|
71
|
-
compress: {
|
|
72
|
-
dead_code: false,
|
|
73
|
-
side_effects: false
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const response = await minify(content, config);
|
|
77
|
-
return response.code
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
getBundle() {
|
|
81
|
-
const out = [];
|
|
82
|
-
if (this.config.withObject === false) out.push(`'use strict'`);
|
|
59
|
+
if (strict) out.push(`'use strict'`);
|
|
83
60
|
out.push('const templates = {}');
|
|
84
61
|
Object.entries(this.templates).forEach(([name, content]) => {
|
|
85
62
|
name = JSON.stringify(name);
|
|
86
63
|
content = String(content);
|
|
87
64
|
out.push(`templates[${name}] = ${content}`);
|
|
88
65
|
});
|
|
66
|
+
if (umd) {
|
|
67
|
+
out.push('return templates}))');
|
|
68
|
+
} else {
|
|
69
|
+
out.push('export default templates');
|
|
70
|
+
}
|
|
89
71
|
return out.join('\n')
|
|
90
72
|
}
|
|
91
73
|
async watch() {
|
|
@@ -131,11 +113,7 @@ class Bundler {
|
|
|
131
113
|
|
|
132
114
|
async output() {
|
|
133
115
|
const target = [].concat(this.options.target);
|
|
134
|
-
|
|
135
|
-
if (this.options.minify) {
|
|
136
|
-
content = await this.stageMinify(content);
|
|
137
|
-
}
|
|
138
|
-
content = this.stageWrapper(content);
|
|
116
|
+
const content = this.getBundle();
|
|
139
117
|
for (let file of target) {
|
|
140
118
|
const folderPath = dirname(file);
|
|
141
119
|
const folderExists = await promises
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "EJS Templates",
|
|
4
4
|
"homepage": "https://github.com/kosatyi/ejs",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.87",
|
|
7
7
|
"main": "dist/cjs/index.js",
|
|
8
8
|
"module": "dist/esm/index.js",
|
|
9
9
|
"browser": "dist/umd/browser.js",
|
|
@@ -57,13 +57,14 @@
|
|
|
57
57
|
},
|
|
58
58
|
"keywords": [
|
|
59
59
|
"ejs",
|
|
60
|
-
"
|
|
61
|
-
"
|
|
60
|
+
"ejs-express",
|
|
61
|
+
"ejs-cloudflare",
|
|
62
|
+
"ejs-template-engine"
|
|
62
63
|
],
|
|
63
64
|
"peerDependencies": {
|
|
64
65
|
"glob": "11.x",
|
|
65
66
|
"process.argv": "1.x",
|
|
66
|
-
"
|
|
67
|
+
"glob-watcher": "6.x"
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
70
|
"@babel/preset-env": "^7.26.0",
|
|
@@ -74,8 +75,5 @@
|
|
|
74
75
|
"rollup": "^4.28.1",
|
|
75
76
|
"rollup-plugin-copy": "^3.5.0",
|
|
76
77
|
"rollup-plugin-ignore": "^1.0.10"
|
|
77
|
-
},
|
|
78
|
-
"dependencies": {
|
|
79
|
-
"glob-watcher": "^6.0.0"
|
|
80
78
|
}
|
|
81
79
|
}
|