Open developit opened 6 years ago
It's a pretty simple function, so I would hope it could! I don't use babel or know how to make plugins for it, but I'd hope someone would consider it!
Unsure if should keep open here.
There is a similar thing implemented by dedent
called "babel-macro", but I'm not sure if it needs to be a part of theredoc
or a separate thing.
https://www.npmjs.com/package/dedent https://github.com/dmnd/dedent/blob/master/macro.js
I hadn't heard of babel-macros before, it's a pretty great idea. All you need to do is:
npm i babel-plugin-macros dedent
Add macros
to your list of babel plugins (wherever your babel config is)
Use dedent e.g.
import dedent from 'dedent/macro'
logIndentedString()
function logIndentedString() {
console.log(dedent(`
This string
is properly indented
at compile time
`))
}
This is failing on my jenkins build no node 4 support :(
node_modules/theredoc/index.js:1
(function (exports, require, module, __filename, __dirname) { module.exports = function theredoc (strings, ...values) {
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
theredoc is failing or attempting to write a Babel macro is failing?
Part of why I waited to publish theredoc until now was that Node 4 was EOL'd on 4/30/18 and I finally felt comfortable dropping support from new releases of our open source.
On May 7, 2018, at 3:49 PM, Thomas Reggi notifications@github.com wrote:
This is failing on my jenkins build no node 4 support :(
node_modules/theredoc/index.js:1 (function (exports, require, module, filename, dirname) { module.exports = function theredoc (strings, ...values) { ^^^
SyntaxError: Unexpected token ... at exports.runInThisContext (vm.js:53:16)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
It'd be awesome to have this with no runtime cost. Could it be done as a babel plugin?