marko-js / marko

A declarative, HTML-based language that makes building web apps fun
https://markojs.com/
MIT License
13.28k stars 641 forks source link

Markojs Windows - rollup - paths #778

Closed kure- closed 6 years ago

kure- commented 6 years ago

Bug Report

When using server side rendering with Express and using <include('../path', data)/> in Windows, the compiled javascript for the template result in: // Compiled using marko@4.4.21 - DO NOT EDIT "use strict"; var marko_template = module.exports = require("marko/src/html").t(__filename), marko_getCurrentComponent = require("marko/src/components/taglib/helpers/getCurrentComponent"), helpers_module = require("../../public/javascripts/helpers/helpers"), titleify = helpers_module.titleify, marko_forEachPropStatusVar = require("marko/src/runtime/helper-forEachPropStatusVar"), forEacPropStatusVar = marko_forEachPropStatusVar, marko_helpers = require("marko/src/runtime/html/helpers"), marko_escapeXml = marko_helpers.x, marko_escapeXmlAttr = marko_helpers.xa, marko_forEachProp = require("marko/src/runtime/helper-forEachProperty"), marko_attr = marko_helpers.a, marko_loadTag = marko_helpers.t, w_preserve_tag = marko_loadTag(require("marko/src/components\\taglib\\preserve-tag"));

`function render(input, out) { var data = input;

var __component = marko_getCurrentComponent(out);

var componentId1 = component.elId("0[]");

w_preserve_tag({ id: __componentId1, renderBody: function renderBody(out) { out.w("<div" + marko_attr("id", __componentId1) + ">");`

  forEacPropStatusVar(data, function(key, module, loop) {
    let paddingClass = 'pt-3'

    if (loop.isFirst()) {
      paddingClass = 'pt-2'
    }

    out.w("<div class=\"" +
      marko_escapeXmlAttr(paddingClass) +
      "\"><button data-toggle=\"collapse\" data-target=\"#collapse" +
      marko_escapeXmlAttr(key) +
      "\" type=\"button\" class=\"btn btn-default btn-block\">" +
      marko_escapeXml(titleify(key)) +
      "</button><div id=\"collapse" +
      marko_escapeXmlAttr(key) +
      "\" data-name=\"" +
      marko_escapeXmlAttr(key) +
      "\" class=\"collapse moduleCheckboxes\">");

    marko_forEachProp(module, function(pluginKey, plugin) {
      out.w("<label class=\"form-check-label d-block mt-2\"><input type=\"checkbox\" value=\"" +
        marko_escapeXmlAttr(pluginKey) +
        "\" id=\"" +
        marko_escapeXmlAttr(pluginKey) +
        "\">" +
        marko_escapeXml(titleify(pluginKey)) +
        "</label>");
    });

    out.w("</div></div>");
  });

  out.w("</div>");
}

}, out); }`

markotemplate. = render;

marko_template.meta = { tags: [ "marko/src/components\\taglib\\preserve-tag" ] };


The important part, I think, is that the loadTag and template meta transforms with "\\". The console throws an error: Error: Could not resolve 'marko/src/components aglibpreserve-tag' from E:\xampp\htdocs\project\project\views\formFields\index.marko

The include() is called within a structure: ./views/app/index.marko ./views/formFields/index.marko

The content of formFields/index.marko is: `import { titleify } from '../../public/javascripts/helpers/helpers';

$ let paddingClass = 'pt-3' $ paddingClass = 'pt-2'
` ### Context Everything works fine on Linux, MacOS. The problem which I don't understand is, that if I remove the include tags from the template, starts the app, everything is fine (elements are not there). Then on the runtime I insert the include tags back, it recompiles, it throws an error but the elements appear. ### Possible Fix
Additional Info ### Your Environment * Version used: 4.4.21 * Environment name and version (e.g. Chrome 39, node.js 5.4): node v7.8.0 * Operating System and version (desktop or mobile): Windows 8.1 (desktop) * Link to your project:
kure- commented 6 years ago

Sorry, the code blocks just breaks

VojtechKlos commented 6 years ago

Same happens on my Windows 10 machine, Chrome 52, node 8.2.1. Exact same errors. Can you please ellaborate on how this can be fixed and if it can be fixed?

austinkelleher commented 6 years ago

@kure- Are you using webpack?

kure- commented 6 years ago

@austinkelleher rollup it is in this case

austinkelleher commented 6 years ago

Just an update. I have a fix for this and will be putting up a PR soon.

kure- commented 6 years ago

@austinkelleher great thank you :)

austinkelleher commented 6 years ago

@kure- @VojtechKlos This issue is fixed in marko@4.4.25. Thanks for the detailed report.

kure- commented 6 years ago

@austinkelleher you rock, thanks for the notice and update! Everything runs smoothly now ;)