@kosatyi/ejs 0.0.81 → 0.0.82

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 CHANGED
@@ -8,8 +8,6 @@ const schema = argv(process.argv.slice(2))
8
8
 
9
9
  const params = schema({
10
10
  target: null,
11
- transform: false,
12
- timestamp: true,
13
11
  minify: false,
14
12
  withObject: false,
15
13
  export: 'ejsPrecompiled',
@@ -23,10 +21,9 @@ if (typeof params.target !== 'string') {
23
21
 
24
22
  const options = {
25
23
  target: params.target,
26
- transform: params.transform,
27
- timestamp: params.timestamp,
28
24
  minify: params.minify,
29
25
  }
26
+
30
27
  const config = {
31
28
  withObject: params.withObject,
32
29
  path: params.path,
@@ -5,7 +5,6 @@ var glob = require('glob');
5
5
  var path = require('path');
6
6
  var terser = require('terser');
7
7
  var index_js = require('./index.js');
8
- var babel = require('@babel/core');
9
8
 
10
9
  const isPlainObject = function (obj) {
11
10
  return Object.prototype.toString.call(obj) === '[object Object]'
@@ -21,8 +20,8 @@ class Bundler {
21
20
  */
22
21
  options = {
23
22
  target: [],
24
- transform: true,
25
- minify: true,
23
+ transform: false,
24
+ minify: false,
26
25
  timestamp: true,
27
26
  }
28
27
  /**
@@ -53,20 +52,10 @@ class Bundler {
53
52
  const response = await terser.minify(content, config);
54
53
  return response.code
55
54
  }
56
- async stageTransform(content) {
57
- if (this.options.transform === false) return content
58
- const config = {
59
- presets: [['@babel/preset-env']],
60
- sourceType: 'script',
61
- };
62
- const response = await babel.transformAsync(content, config);
63
- return response.code
64
- }
65
55
  getBundle() {
66
56
  const transform = this.options.transform;
67
57
  const moduleId = this.config.export;
68
58
  const useStrict = this.config.withObject === false;
69
- const timestamp = this.options.timestamp;
70
59
  const out = [];
71
60
  if (transform) {
72
61
  out.push('(function(global,factory){');
@@ -84,7 +73,6 @@ class Bundler {
84
73
  out.push('})(this,(function(){');
85
74
  }
86
75
  if (useStrict) out.push("'use strict'");
87
- if (timestamp) out.push('const timestamp = '.concat(String(Date.now())));
88
76
  out.push('const templates = {}');
89
77
  Object.entries(this.templates).forEach(([name, content]) => {
90
78
  name = JSON.stringify(name);
@@ -100,12 +88,12 @@ class Bundler {
100
88
  return out.join('\n')
101
89
  }
102
90
  async watch() {
103
- console.log(`ejs-bundle: watching directory - ${this.config.path}`);
91
+ console.log(`ejs-bundler: watching directory - ${this.config.path}`);
104
92
  try {
105
93
  const watcher = fs.promises.watch(this.config.path, { recursive: true });
106
94
  for await (const { filename } of watcher) {
107
95
  if (path.extname(filename).slice(1) === this.config.extension) {
108
- console.log(`ejs-bundle: file is changed - ${filename}`);
96
+ console.log(`ejs-bundler: file is changed - ${filename}`);
109
97
  await this.build();
110
98
  }
111
99
  }
@@ -118,7 +106,7 @@ class Bundler {
118
106
  this.buildInProgress = true;
119
107
  await this.concat().catch(console.error);
120
108
  await this.output().catch(console.error);
121
- console.log(`ejs-bundle: bundle complete - ${this.options.target}`);
109
+ console.log(`ejs-bundler: bundle complete - ${this.options.target}`);
122
110
  this.buildInProgress = false;
123
111
  }
124
112
  async concat() {
@@ -134,9 +122,6 @@ class Bundler {
134
122
  async output() {
135
123
  const target = [].concat(this.options.target);
136
124
  let content = this.getBundle();
137
- if (this.options.transform) {
138
- content = await this.stageTransform(content);
139
- }
140
125
  if (this.options.minify) {
141
126
  content = await this.stageMinify(content);
142
127
  }
@@ -154,10 +139,10 @@ class Bundler {
154
139
  }
155
140
  }
156
141
 
157
- const ejsBundle = (options, config) => {
142
+ const ejsBundler = (options, config) => {
158
143
  const bundler = new Bundler(options, config);
159
144
  return {
160
- name: 'ejs-bundle',
145
+ name: 'ejs-bundler',
161
146
  async buildStart() {
162
147
  await bundler.concat();
163
148
  },
@@ -168,4 +153,4 @@ const ejsBundle = (options, config) => {
168
153
  };
169
154
 
170
155
  exports.Bundler = Bundler;
171
- exports.ejsBundle = ejsBundle;
156
+ exports.ejsBundler = ejsBundler;
@@ -3,7 +3,6 @@ import { glob } from 'glob';
3
3
  import { join, extname, dirname } from 'path';
4
4
  import { minify } from 'terser';
5
5
  import { configure, compile } from './index.js';
6
- import babel from '@babel/core';
7
6
 
8
7
  const isPlainObject = function (obj) {
9
8
  return Object.prototype.toString.call(obj) === '[object Object]'
@@ -19,8 +18,8 @@ class Bundler {
19
18
  */
20
19
  options = {
21
20
  target: [],
22
- transform: true,
23
- minify: true,
21
+ transform: false,
22
+ minify: false,
24
23
  timestamp: true,
25
24
  }
26
25
  /**
@@ -51,20 +50,10 @@ class Bundler {
51
50
  const response = await minify(content, config);
52
51
  return response.code
53
52
  }
54
- async stageTransform(content) {
55
- if (this.options.transform === false) return content
56
- const config = {
57
- presets: [['@babel/preset-env']],
58
- sourceType: 'script',
59
- };
60
- const response = await babel.transformAsync(content, config);
61
- return response.code
62
- }
63
53
  getBundle() {
64
54
  const transform = this.options.transform;
65
55
  const moduleId = this.config.export;
66
56
  const useStrict = this.config.withObject === false;
67
- const timestamp = this.options.timestamp;
68
57
  const out = [];
69
58
  if (transform) {
70
59
  out.push('(function(global,factory){');
@@ -82,7 +71,6 @@ class Bundler {
82
71
  out.push('})(this,(function(){');
83
72
  }
84
73
  if (useStrict) out.push("'use strict'");
85
- if (timestamp) out.push('const timestamp = '.concat(String(Date.now())));
86
74
  out.push('const templates = {}');
87
75
  Object.entries(this.templates).forEach(([name, content]) => {
88
76
  name = JSON.stringify(name);
@@ -98,12 +86,12 @@ class Bundler {
98
86
  return out.join('\n')
99
87
  }
100
88
  async watch() {
101
- console.log(`ejs-bundle: watching directory - ${this.config.path}`);
89
+ console.log(`ejs-bundler: watching directory - ${this.config.path}`);
102
90
  try {
103
91
  const watcher = promises.watch(this.config.path, { recursive: true });
104
92
  for await (const { filename } of watcher) {
105
93
  if (extname(filename).slice(1) === this.config.extension) {
106
- console.log(`ejs-bundle: file is changed - ${filename}`);
94
+ console.log(`ejs-bundler: file is changed - ${filename}`);
107
95
  await this.build();
108
96
  }
109
97
  }
@@ -116,7 +104,7 @@ class Bundler {
116
104
  this.buildInProgress = true;
117
105
  await this.concat().catch(console.error);
118
106
  await this.output().catch(console.error);
119
- console.log(`ejs-bundle: bundle complete - ${this.options.target}`);
107
+ console.log(`ejs-bundler: bundle complete - ${this.options.target}`);
120
108
  this.buildInProgress = false;
121
109
  }
122
110
  async concat() {
@@ -132,9 +120,6 @@ class Bundler {
132
120
  async output() {
133
121
  const target = [].concat(this.options.target);
134
122
  let content = this.getBundle();
135
- if (this.options.transform) {
136
- content = await this.stageTransform(content);
137
- }
138
123
  if (this.options.minify) {
139
124
  content = await this.stageMinify(content);
140
125
  }
@@ -152,10 +137,10 @@ class Bundler {
152
137
  }
153
138
  }
154
139
 
155
- const ejsBundle = (options, config) => {
140
+ const ejsBundler = (options, config) => {
156
141
  const bundler = new Bundler(options, config);
157
142
  return {
158
- name: 'ejs-bundle',
143
+ name: 'ejs-bundler',
159
144
  async buildStart() {
160
145
  await bundler.concat();
161
146
  },
@@ -165,4 +150,4 @@ const ejsBundle = (options, config) => {
165
150
  }
166
151
  };
167
152
 
168
- export { Bundler, ejsBundle };
153
+ export { Bundler, ejsBundler };
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.81",
6
+ "version": "0.0.82",
7
7
  "main": "dist/cjs/index.js",
8
8
  "module": "dist/esm/index.js",
9
9
  "browser": "dist/umd/browser.js",
@@ -61,13 +61,12 @@
61
61
  "nodejs"
62
62
  ],
63
63
  "peerDependencies": {
64
- "@babel/core": "7.x",
65
- "@babel/preset-env": "7.x",
66
64
  "glob": "11.x",
67
65
  "process.argv": "1.x",
68
66
  "terser": "5.x"
69
67
  },
70
68
  "devDependencies": {
69
+ "@babel/preset-env": "^7.26.0",
71
70
  "@rollup/plugin-babel": "^6.0.4",
72
71
  "@rollup/plugin-commonjs": "^28.0.1",
73
72
  "@rollup/plugin-node-resolve": "^15.3.0",
@@ -10,16 +10,9 @@ export interface EjsConfig {
10
10
 
11
11
  export interface BundlerOptions {
12
12
  target: string[] | string
13
- transform?: boolean
14
- timestamp?: boolean
15
13
  minify?: boolean
16
14
  }
17
15
 
18
- export interface WatcherOptions {
19
- dir: string
20
- pattern?: string
21
- }
22
-
23
16
  export function ejsBundle(
24
17
  options: BundlerOptions | object,
25
18
  config: EjsConfig | object