@marko/vite 2.4.6 → 2.4.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/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);
@@ -357,42 +374,20 @@ function markoPlugin(opts = {}) {
357
374
  basePath,
358
375
  await devServer.transformIndexHtml(
359
376
  "/",
360
- (0, import_manifest_generator.generateInputDoc)(posixFileNameToURL(fileName, root))
377
+ (0, import_manifest_generator.generateInputDoc)(
378
+ posixFileNameToURL(fileName, root) + browserEntryQuery
379
+ )
361
380
  )
362
381
  )
363
382
  );
364
383
  }
365
- return (0, import_server_entry_template.default)({
384
+ source = await (0, import_server_entry_template.default)({
366
385
  fileName,
367
386
  entryData,
368
387
  runtimeId,
369
388
  basePathVar: isBuild ? basePathVar : void 0
370
389
  });
371
390
  }
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
391
  }
397
392
  if (!isMarkoFile(id)) {
398
393
  return null;
@@ -533,7 +528,7 @@ function toHTMLEntries(root, serverEntries) {
533
528
  const markoFile = import_path.default.posix.join(root, serverEntries[id]);
534
529
  const htmlFile = markoFile + htmlExt;
535
530
  virtualFiles.set(htmlFile, {
536
- code: (0, import_manifest_generator.generateInputDoc)(markoFile)
531
+ code: (0, import_manifest_generator.generateInputDoc)(markoFile + browserEntryQuery)
537
532
  });
538
533
  result.push(htmlFile);
539
534
  }
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);
@@ -337,42 +354,20 @@ function markoPlugin(opts = {}) {
337
354
  basePath,
338
355
  await devServer.transformIndexHtml(
339
356
  "/",
340
- generateInputDoc(posixFileNameToURL(fileName, root))
357
+ generateInputDoc(
358
+ posixFileNameToURL(fileName, root) + browserEntryQuery
359
+ )
341
360
  )
342
361
  )
343
362
  );
344
363
  }
345
- return server_entry_template_default({
364
+ source = await server_entry_template_default({
346
365
  fileName,
347
366
  entryData,
348
367
  runtimeId,
349
368
  basePathVar: isBuild ? basePathVar : void 0
350
369
  });
351
370
  }
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
371
  }
377
372
  if (!isMarkoFile(id)) {
378
373
  return null;
@@ -513,7 +508,7 @@ function toHTMLEntries(root, serverEntries) {
513
508
  const markoFile = path.posix.join(root, serverEntries[id]);
514
509
  const htmlFile = markoFile + htmlExt;
515
510
  virtualFiles.set(htmlFile, {
516
- code: generateInputDoc(markoFile)
511
+ code: generateInputDoc(markoFile + browserEntryQuery)
517
512
  });
518
513
  result.push(htmlFile);
519
514
  }
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.7",
5
5
  "author": "Dylan Piercey <dpiercey@ebay.com>",
6
6
  "bugs": "https://github.com/marko-js/vite/issues",
7
7
  "dependencies": {