Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[js] Fixing using module names that contain :: like QAST::Compiler.
  • Loading branch information
pmurias committed Mar 9, 2016
1 parent 8646ab1 commit deb4ce6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/vm/js/Compiler.nqp
Expand Up @@ -1176,9 +1176,20 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
}
}

my sub literal_subst($source, $pattern, $replacement) {
my $where := 0;
my $result := $source;
while (my $found := nqp::index($result, $pattern, $where)) != -1 {
$where := $found + nqp::chars($replacement);
$result := nqp::replace($result, $found, nqp::chars($pattern), $replacement);
};
$result;
}

my sub loadable($name) {
# workaround for webpack
quote_string($name) ~ ", function() \{return require({quote_string($name)})\}";
my $path := literal_subst($name, '::', '/');
quote_string($name) ~ ", function() \{return require({quote_string($path)})\}";
}

multi method as_js(QAST::CompUnit $node, :$want, :$cps) {
Expand Down

0 comments on commit deb4ce6

Please sign in to comment.