lilact 0.26.5 → 0.26.7

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/bundle.cjs CHANGED
@@ -100,7 +100,7 @@ function parseArgs(argv) {
100
100
  if (!k || !k.startsWith("--")) continue;
101
101
  const key = k.slice(2);
102
102
 
103
- if (key === "watch" || key === "minify") {
103
+ if (key === "watch" || key === "minify" || key === "split") {
104
104
  args[key] = true;
105
105
  continue;
106
106
  }
@@ -118,22 +118,20 @@ async function run() {
118
118
 
119
119
  if (!userEntry) {
120
120
  console.error(
121
- "Usage: lilact-bundler --watch --minify --entry ./path/to/entry.js --mode production --out ./dist --name bundle.js"
121
+ "Usage: lilact-bundler --watch --minify --entry ./path/to/entry.js --mode production --out ./dist"
122
122
  );
123
123
  process.exit(1);
124
124
  }
125
125
 
126
- const name = args.name ?? "bundle.js";
127
126
  const mode = args.mode ?? "production";
128
127
  const watch = args?.watch === true;
129
128
  const minify = args?.minify === true;
129
+ const split = args?.split === true;
130
130
 
131
131
  const userOutDir = args.out
132
132
  ? path.resolve(userProjectRoot, args.out)
133
133
  : path.resolve(userProjectRoot, "dist");
134
134
 
135
- const outFile = path.join(userOutDir, name);
136
-
137
135
  const define = {
138
136
  DEBUG: JSON.stringify(mode === "development"),
139
137
  };
@@ -144,19 +142,21 @@ async function run() {
144
142
  name: "log-on-build",
145
143
  setup(build) {
146
144
  build.onStart(() => {
147
- console.log(`Rebuilt: ${outFile} (${new Date().toISOString()})`);
145
+ console.log(`Rebuilt: ${new Date().toISOString()}`);
148
146
  });
149
147
  },
150
148
  };
151
149
 
152
150
  const ctx = await esbuild.context({
153
- entryPoints: [userEntry],
151
+ entryPoints: {bundle: userEntry},
154
152
  bundle: true,
155
153
  format: "esm",
156
154
  platform: "browser",
157
155
 
158
- outfile: outFile,
159
- sourcemap: true,
156
+ outdir: userOutDir,
157
+ splitting: split,
158
+
159
+ sourcemap: true,
160
160
  target: ["es2018"],
161
161
 
162
162
  minify: minify,
@@ -186,26 +186,9 @@ async function run() {
186
186
  }
187
187
  };
188
188
 
189
- const buildOpts = {
190
- entryPoints: [userEntry],
191
- bundle: true,
192
- format: "esm",
193
- platform: "browser",
194
- outfile: outFile,
195
- sourcemap: true,
196
- target: ["es2018"],
197
- minify: minify,
198
- define,
199
- loader: { ".js": "js", ".jsx": "jsx", ".css": "css" },
200
- resolveExtensions: [".js", ".jsx", ".json"],
201
- absWorkingDir: userProjectRoot,
202
- plugins: [createLilactJsxPlugin({ mode })],
203
- banner: { js: licenseBanner },
204
- };
205
-
206
189
  if (watch) {
207
190
  await ctx.watch();
208
- console.log(`Watching... output: ${outFile}`);
191
+ console.log(`Watching...`);
209
192
  } else {
210
193
  await ctx.rebuild();
211
194
  await shutdown();
@@ -5619,7 +5619,7 @@ function processImportExports(node3, jsx2) {
5619
5619
  o += "}";
5620
5620
  ls += "]";
5621
5621
  cjs += `const ${o} = require(${src}, {checkExport: ${ls},requirer:module})`;
5622
- } else {
5622
+ } else if (cjs.length === 0) {
5623
5623
  cjs += `require(${src},{requirer:module})`;
5624
5624
  }
5625
5625
  node3.out[m.index].cjs = cjs;