@marko/vite 2.4.6 → 2.4.8

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/dist/index.js CHANGED
@@ -338,9 +338,26 @@ function markoPlugin(opts = {}) {
338
338
  const query = getMarkoQuery(id);
339
339
  switch (query) {
340
340
  case serverEntryQuery: {
341
- const fileName = id.slice(0, -query.length);
341
+ entryIds.add(id.slice(0, -query.length));
342
+ return null;
343
+ }
344
+ case browserEntryQuery:
345
+ case browserQuery: {
346
+ return cachedSources.get(id.slice(0, -query.length)) || null;
347
+ }
348
+ }
349
+ return virtualFiles.get(id) || null;
350
+ },
351
+ async transform(source, id, ssr) {
352
+ const isSSR = typeof ssr === "object" ? ssr.ssr : ssr;
353
+ const query = getMarkoQuery(id);
354
+ if (query && !query.startsWith(virtualFileQuery)) {
355
+ id = id.slice(0, -query.length);
356
+ if (query === serverEntryQuery) {
357
+ const fileName = id;
342
358
  let entryData;
343
- entryIds.add(fileName);
359
+ id = `${id.slice(0, -markoExt.length)}.entry.marko`;
360
+ cachedSources.set(fileName, source);
344
361
  if (isBuild) {
345
362
  const relativeFileName = import_path.default.posix.relative(root, fileName);
346
363
  const entryId = toEntryId(relativeFileName);
@@ -350,6 +367,7 @@ function markoPlugin(opts = {}) {
350
367
  chunksNeedingAssets: []
351
368
  });
352
369
  serverManifest.entries[entryId] = relativeFileName;
370
+ serverManifest.entrySources[relativeFileName] = source;
353
371
  entryData = JSON.stringify(entryId);
354
372
  } else {
355
373
  entryData = JSON.stringify(
@@ -357,42 +375,20 @@ function markoPlugin(opts = {}) {
357
375
  basePath,
358
376
  await devServer.transformIndexHtml(
359
377
  "/",
360
- (0, import_manifest_generator.generateInputDoc)(posixFileNameToURL(fileName, root))
378
+ (0, import_manifest_generator.generateInputDoc)(
379
+ posixFileNameToURL(fileName, root) + browserEntryQuery
380
+ )
361
381
  )
362
382
  )
363
383
  );
364
384
  }
365
- return (0, import_server_entry_template.default)({
385
+ source = await (0, import_server_entry_template.default)({
366
386
  fileName,
367
387
  entryData,
368
388
  runtimeId,
369
389
  basePathVar: isBuild ? basePathVar : void 0
370
390
  });
371
391
  }
372
- case browserEntryQuery:
373
- case browserQuery: {
374
- return cachedSources.get(id.slice(0, -query.length)) || null;
375
- }
376
- }
377
- return virtualFiles.get(id) || null;
378
- },
379
- async transformIndexHtml(html) {
380
- if (isBuild) {
381
- return html;
382
- }
383
- return html.replace(
384
- /(src\s*=\s*(['"])(?:(?!\2).)*\.marko)(?:\?((?:(?!\2).)*))?\2/gim,
385
- (_, prefix, quote, query) => prefix + browserEntryQuery + (query ? "&" + query : "") + quote
386
- );
387
- },
388
- async transform(source, id, ssr) {
389
- const isSSR = typeof ssr === "object" ? ssr.ssr : ssr;
390
- const query = getMarkoQuery(id);
391
- if (query && !query.startsWith(virtualFileQuery)) {
392
- id = id.slice(0, -query.length);
393
- if (query === serverEntryQuery) {
394
- id = `${id.slice(0, -markoExt.length)}.entry.marko`;
395
- }
396
392
  }
397
393
  if (!isMarkoFile(id)) {
398
394
  return null;
@@ -400,9 +396,6 @@ function markoPlugin(opts = {}) {
400
396
  if (isSSR) {
401
397
  if (linked) {
402
398
  cachedSources.set(id, source);
403
- if (serverManifest && entryIds.has(id)) {
404
- serverManifest.entrySources[import_path.default.posix.relative(root, id)] = source;
405
- }
406
399
  }
407
400
  if (CJSTemplates == null ? void 0 : CJSTemplates.has(id)) {
408
401
  return createEsmWrapper(
@@ -533,7 +526,7 @@ function toHTMLEntries(root, serverEntries) {
533
526
  const markoFile = import_path.default.posix.join(root, serverEntries[id]);
534
527
  const htmlFile = markoFile + htmlExt;
535
528
  virtualFiles.set(htmlFile, {
536
- code: (0, import_manifest_generator.generateInputDoc)(markoFile)
529
+ code: (0, import_manifest_generator.generateInputDoc)(markoFile + browserEntryQuery)
537
530
  });
538
531
  result.push(htmlFile);
539
532
  }
package/dist/index.mjs CHANGED
@@ -318,9 +318,26 @@ function markoPlugin(opts = {}) {
318
318
  const query = getMarkoQuery(id);
319
319
  switch (query) {
320
320
  case serverEntryQuery: {
321
- const fileName = id.slice(0, -query.length);
321
+ entryIds.add(id.slice(0, -query.length));
322
+ return null;
323
+ }
324
+ case browserEntryQuery:
325
+ case browserQuery: {
326
+ return cachedSources.get(id.slice(0, -query.length)) || null;
327
+ }
328
+ }
329
+ return virtualFiles.get(id) || null;
330
+ },
331
+ async transform(source, id, ssr) {
332
+ const isSSR = typeof ssr === "object" ? ssr.ssr : ssr;
333
+ const query = getMarkoQuery(id);
334
+ if (query && !query.startsWith(virtualFileQuery)) {
335
+ id = id.slice(0, -query.length);
336
+ if (query === serverEntryQuery) {
337
+ const fileName = id;
322
338
  let entryData;
323
- entryIds.add(fileName);
339
+ id = `${id.slice(0, -markoExt.length)}.entry.marko`;
340
+ cachedSources.set(fileName, source);
324
341
  if (isBuild) {
325
342
  const relativeFileName = path.posix.relative(root, fileName);
326
343
  const entryId = toEntryId(relativeFileName);
@@ -330,6 +347,7 @@ function markoPlugin(opts = {}) {
330
347
  chunksNeedingAssets: []
331
348
  });
332
349
  serverManifest.entries[entryId] = relativeFileName;
350
+ serverManifest.entrySources[relativeFileName] = source;
333
351
  entryData = JSON.stringify(entryId);
334
352
  } else {
335
353
  entryData = JSON.stringify(
@@ -337,42 +355,20 @@ function markoPlugin(opts = {}) {
337
355
  basePath,
338
356
  await devServer.transformIndexHtml(
339
357
  "/",
340
- generateInputDoc(posixFileNameToURL(fileName, root))
358
+ generateInputDoc(
359
+ posixFileNameToURL(fileName, root) + browserEntryQuery
360
+ )
341
361
  )
342
362
  )
343
363
  );
344
364
  }
345
- return server_entry_template_default({
365
+ source = await server_entry_template_default({
346
366
  fileName,
347
367
  entryData,
348
368
  runtimeId,
349
369
  basePathVar: isBuild ? basePathVar : void 0
350
370
  });
351
371
  }
352
- case browserEntryQuery:
353
- case browserQuery: {
354
- return cachedSources.get(id.slice(0, -query.length)) || null;
355
- }
356
- }
357
- return virtualFiles.get(id) || null;
358
- },
359
- async transformIndexHtml(html) {
360
- if (isBuild) {
361
- return html;
362
- }
363
- return html.replace(
364
- /(src\s*=\s*(['"])(?:(?!\2).)*\.marko)(?:\?((?:(?!\2).)*))?\2/gim,
365
- (_, prefix, quote, query) => prefix + browserEntryQuery + (query ? "&" + query : "") + quote
366
- );
367
- },
368
- async transform(source, id, ssr) {
369
- const isSSR = typeof ssr === "object" ? ssr.ssr : ssr;
370
- const query = getMarkoQuery(id);
371
- if (query && !query.startsWith(virtualFileQuery)) {
372
- id = id.slice(0, -query.length);
373
- if (query === serverEntryQuery) {
374
- id = `${id.slice(0, -markoExt.length)}.entry.marko`;
375
- }
376
372
  }
377
373
  if (!isMarkoFile(id)) {
378
374
  return null;
@@ -380,9 +376,6 @@ function markoPlugin(opts = {}) {
380
376
  if (isSSR) {
381
377
  if (linked) {
382
378
  cachedSources.set(id, source);
383
- if (serverManifest && entryIds.has(id)) {
384
- serverManifest.entrySources[path.posix.relative(root, id)] = source;
385
- }
386
379
  }
387
380
  if (CJSTemplates == null ? void 0 : CJSTemplates.has(id)) {
388
381
  return createEsmWrapper(
@@ -513,7 +506,7 @@ function toHTMLEntries(root, serverEntries) {
513
506
  const markoFile = path.posix.join(root, serverEntries[id]);
514
507
  const htmlFile = markoFile + htmlExt;
515
508
  virtualFiles.set(htmlFile, {
516
- code: generateInputDoc(markoFile)
509
+ code: generateInputDoc(markoFile + browserEntryQuery)
517
510
  });
518
511
  result.push(htmlFile);
519
512
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@marko/vite",
3
3
  "description": "A Marko plugin for Vite",
4
- "version": "2.4.6",
4
+ "version": "2.4.8",
5
5
  "author": "Dylan Piercey <dpiercey@ebay.com>",
6
6
  "bugs": "https://github.com/marko-js/vite/issues",
7
7
  "dependencies": {