question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Requiring library with multiline strings adds tabs

See original GitHub issue

In my project I am requiring in a library from node_modules which contains a block of code similar to the following:

var someVariable = 'line1\
line2\
line3\
line4';

This is a valid, though not recommended, way to use multiline strings in Javascript. The issue occurs after I bundle my project with WebPack. The output looks something like this:

.. function(module,exports,__webpack_require__){ /* other code */ var someVariable='line1   line2   line3   line4'; ...

Tabs are added into the multiline string. I get the same result even when I don’t minify/uglify the output. The block of code is indented in the output and the multiline string now has the same tabs prepended to each line:

    var someVariable = 'line1\
    line2\
    line3\
    line4';

Is there something I’m doing wrong that multiline strings get their values changed, or is this a bug in WebPack?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
donaldpipowitchcommented, Apr 29, 2016

Could output.sourcePrefix default to ''? I was bitten by this recently. Tabs seem to be to dangerous for ES6 multiline strings.

0reactions
webpack-botcommented, Sep 10, 2017

Issue was closed because of inactivity.

If you think this is still a valid issue, please file a new issue with additional information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Proper indentation for multiline strings? - python
When I need a non long string in my code I find the following admittedly ugly code where I let the long string...
Read more >
Changing the Indentation of a Multiline String - O'Reilly
Problem. You have a string made up of multiple lines, and you need to build another string from it, adding or removing leading...
Read more >
Proper Indentation for Python Multiline Strings - Finxter
In this article we are going to look at how to properly indent your code for Python multiline strings, so let's start by...
Read more >
Coding conventions | Kotlin Documentation
val mutableCollection: MutableSet<String> = HashSet() ... if the initializer is long, add a line break after the = sign and indent the ...
Read more >
Python multi-line string literals with textwrap.dedent()
You're writing some Python, and you need to write out a string containing ... You could manually add that leading whitespace, but there's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found