Open cpannwitz opened 6 years ago
I have experienced the exact same problem with scope.macro
, while other macros work, e.g. it
from param.macro.
Get the same error message 😣
Found the problem.
@mattphillips
const buildLog = template => (...args) => level => {
if (level == 0) {
return template('console.log(args);')({ args });
}
const indentation = indentWith(level, '| ', '| ');
return template(`
if (typeof window !== 'undefined') {
console.log(args);
} else {
console.log('${indentation}', args);
}
`)({ args });
};
Should be:
const buildLog = template => (...args) => level => {
if (level == 0) {
return template('console.log(ARGS);')({ ARGS });
}
const indentation = indentWith(level, '| ', '| ');
return template(`
if (typeof window !== 'undefined') {
console.log(ARGS);
} else {
console.log('${indentation}', ARGS);
}
`)({ ARGS });
};
There are also other usages that need changing.
Placeholders must be capitalized.
Note the lowercase placeholder in the babel template.
https://babeljs.io/docs/en/next/babel-template.html#placeholderpattern:
placeholderPattern Type: RegExp | false Default: /^[_$A-Z0-9]+$/
A pattern to search for when looking for Identifier and StringLiteral nodes that should be considered placeholders. 'false' will disable placeholder searching entirely, leaving only the 'placeholderWhitelist' value to find placeholders.
Experiencing this issue with CRAv3
Using Typescript with CRA on MacOS.
Bug
babel-plugin-console
version: 0.2.1node
version: 9.5.0npm
(oryarn
) version: yarn 1.7.0Relevant code or config
What you did:
npx create-react-app@next --scripts-version=2.0.0-next.66cc7a90
yarn add babel-plugin-console
&yarn add scope.macro
App.js
yarn start
What happened (please provide anything you think will help):
As far as I know, the upcoming Create-React-App version 2 comes with built-in support for babel-macros. I also checked with another babel-macro plugin, which is working fine.
Edit: missed a line.