kentcdodds / kcd-scripts Goto Github PK
View Code? Open in Web Editor NEWCLI toolbox for common scripts for my projects
Home Page: http://npm.im/kcd-scripts
License: MIT License
CLI toolbox for common scripts for my projects
Home Page: http://npm.im/kcd-scripts
License: MIT License
kcd-scripts
version: N/Anode
version: N/Anpm
(or yarn
) version: N/ARelevant code or config N/A
What you did: N/A
What happened: N/A
Reproduction repository: N/A
Problem description:
How to bootstrap fresh project with kcd-scripts
? For create-react-app
I do
create-react-app project-name
Suggested solution:
Provide command to bootstrap fresh project or empty github repo which can be used as reference.
As can be seen in https://github.com/MichaelDeBoey/gatsby-plugin-instagram-embed/runs/2317212678#step:6:17 & https://github.com/robinmetral/gatsby-plugin-pinterest/pull/34/checks?check_run_id=2312829302#step:6:33, ESLint errors out on Node 15 with the following error:
Environment key "jest/globals" is unknown
Both packages only use the default ESLint config, without any changes.
I tried to figure out what could be wrong, but I can't find the problem tbh as jest/globals
is set in kentcdodds/jest
ESLint config: https://github.com/kentcdodds/eslint-config-kentcdodds/blob/6f2fc42262e63d3288f409e3e62317456d2aa328/jest.js#L29
Working fine on Node 14 and below though π€
kcd-scripts
version: 0.0.0-semantically-released
πnode
version: 8.5.0
npm
version: 5.3.0
yarn
version: 1.0.2
What you did:
git commit
What happened:
husky > npm run -s precommit (node v8.5.0)
25l[09:24:02] Running tasks for **/*.+(js|json|less|css|ts) [started]
[09:24:02] Running tasks for .all-contributorsrc [started]
[09:24:02] Running tasks for .all-contributorsrc [skipped]
[09:24:02] β No staged files match .all-contributorsrc
[09:24:02] kcd-scripts format [started]
[09:24:03] kcd-scripts format [completed]
[09:24:03] kcd-scripts lint [started]
[09:24:05] kcd-scripts lint [completed]
[09:24:05] kcd-scripts test --findRelatedTests [started]
[09:24:07] kcd-scripts test --findRelatedTests [completed]
[09:24:07] git add [started]
[09:24:07] git add [completed]
[09:24:07] Running tasks for **/*.+(js|json|less|css|ts) [completed]
25h25h
husky > pre-commit hook failed (add --no-verify to bypass)
husky > npm run -s precommit (node v8.5.0)
> [email protected] precommit E:\Projects\repos\kcd-scripts
> node src precommit
25l[09:25:15] Running tasks for **/*.+(js|json|less|css|ts) [started]
[09:25:15] Running tasks for .all-contributorsrc [started]
[09:25:15] Running tasks for .all-contributorsrc [skipped]
[09:25:15] β No staged files match .all-contributorsrc
[09:25:15] kcd-scripts format [started]
[09:25:16] kcd-scripts format [completed]
[09:25:16] kcd-scripts lint [started]
[09:25:18] kcd-scripts lint [completed]
[09:25:18] kcd-scripts test --findRelatedTests [started]
[09:25:20] kcd-scripts test --findRelatedTests [completed]
[09:25:20] git add [started]
[09:25:20] git add [completed]
[09:25:20] Running tasks for **/*.+(js|json|less|css|ts) [completed]
25h25hnpm WARN invalid config access=undefined
npm WARN invalid config also=undefined
npm WARN invalid config https-proxy=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN invalid config init-author-url=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN invalid config only=undefined
npm WARN invalid config proxy=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN onload-script failed to require onload script undefined
npm WARN onload-script Error: Cannot find module 'undefined'
npm WARN onload-script at Function.Module._resolveFilename (module.js:527:15)
npm WARN onload-script at Function.Module._load (module.js:476:23)
npm WARN onload-script at Module.require (module.js:568:17)
npm WARN onload-script at require (internal/module.js:11:18)
npm WARN onload-script at cb (C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:225:11)
npm WARN onload-script at C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:356:16
npm WARN onload-script at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:81:7
npm WARN onload-script at Array.forEach (<anonymous>)
npm WARN onload-script at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:80:13
npm WARN onload-script at f (C:\nvm\v8.5.0\node_modules\npm\node_modules\once\once.js:25:25)
npm WARN onload-script { Error: Cannot find module 'undefined'
npm WARN onload-script at Function.Module._resolveFilename (module.js:527:15)
npm WARN onload-script at Function.Module._load (module.js:476:23)
npm WARN onload-script at Module.require (module.js:568:17)
npm WARN onload-script at require (internal/module.js:11:18)
npm WARN onload-script at cb (C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:225:11)
npm WARN onload-script at C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:356:16
npm WARN onload-script at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:81:7
npm WARN onload-script at Array.forEach (<anonymous>)
npm WARN onload-script at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:80:13
npm WARN onload-script at f (C:\nvm\v8.5.0\node_modules\npm\node_modules\once\once.js:25:25)
npm WARN onload-script stack: 'Error: Cannot find module \'undefined\'\n at Function.Module._resolveFilename (module.js:527:15)\n at Function.Module._load (module.js:476:23)\n at Module.require (module.js:568:17)\n at require (internal/module.js:11:18)\n at cb (C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\npm.js:225:11)\n
at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\npm.js:356:16\n at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\config\\core.js:81:7\n at Array.forEach (<anonymous>)\n at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\config\\core.js:80:13\n at f (C:\\nvm\\v8.5.0\\node_modules\\npm\\node_modules\\once\\once.js:25:25)',
npm WARN onload-script code: 'MODULE_NOT_FOUND' }
npm WARN invalid config access=undefined
npm WARN invalid config also=undefined
npm WARN invalid config https-proxy=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN invalid config init-author-url=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN invalid config only=undefined
npm WARN invalid config proxy=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN onload-script failed to require onload script undefined
npm WARN onload-script Error: Cannot find module 'undefined'
npm WARN onload-script at Function.Module._resolveFilename (module.js:527:15)
npm WARN onload-script at Function.Module._load (module.js:476:23)
npm WARN onload-script at Module.require (module.js:568:17)
npm WARN onload-script at require (internal/module.js:11:18)
npm WARN onload-script at cb (C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:225:11)
npm WARN onload-script at C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:356:16
npm WARN onload-script at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:81:7
npm WARN onload-script at Array.forEach (<anonymous>)
npm WARN onload-script at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:80:13
npm WARN onload-script at f (C:\nvm\v8.5.0\node_modules\npm\node_modules\once\once.js:25:25)
npm WARN onload-script { Error: Cannot find module 'undefined'
npm WARN onload-script at Function.Module._resolveFilename (module.js:527:15)
npm WARN onload-script at Function.Module._load (module.js:476:23)
npm WARN onload-script at Module.require (module.js:568:17)
npm WARN onload-script at require (internal/module.js:11:18)
npm WARN onload-script at cb (C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:225:11)
npm WARN onload-script at C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:356:16
npm WARN onload-script at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:81:7
npm WARN onload-script at Array.forEach (<anonymous>)
npm WARN onload-script at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:80:13
npm WARN onload-script at f (C:\nvm\v8.5.0\node_modules\npm\node_modules\once\once.js:25:25)
npm WARN onload-script stack: 'Error: Cannot find module \'undefined\'\n at Function.Module._resolveFilename (module.js:527:15)\n at Function.Module._load (module.js:476:23)\n at Module.require (module.js:568:17)\n at require (internal/module.js:11:18)\n at cb (C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\npm.js:225:11)\n
at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\npm.js:356:16\n at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\config\\core.js:81:7\n at Array.forEach (<anonymous>)\n at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\config\\core.js:80:13\n at f (C:\\nvm\\v8.5.0\\node_modules\\npm\\node_modules\\once\\once.js:25:25)',
npm WARN onload-script code: 'MODULE_NOT_FOUND' }
> [email protected] validate E:\Projects\repos\kcd-scripts
> node src validate
npm ERR! file undefined
npm ERR! path undefined
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn undefined
npm ERR! [email protected] validate: `node src validate`
npm ERR! spawn undefined ENOENT
npm ERR!
npm ERR! Failed at the [email protected] validate script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! code ELIFECYCLE
npm ERR! errno -4058
npm ERR! [email protected] validate: `node src validate`
npm ERR! Exit status -4058
npm ERR!
npm ERR! Failed at the [email protected] validate script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\suhas.karanth\AppData\Roaming\npm-cache\_logs\2017-09-19T03_55_21_615Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] precommit: `node src precommit`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] precommit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\suhas.karanth\AppData\Roaming\npm-cache\_logs\2017-09-19T03_55_21_791Z-debug.log
husky > pre-commit hook failed (add --no-verify to bypass)
Problem description:
This is related to the issue I had faced with opt-cli
- ta2edchimp/opt-cli#213.
Invoking spawn
with env having undefined
values breaks npm
.
Suggested solution:
While I know how to fix the issue, in kcd-scripts
, I am wondering if the fix should be in cross-spawn
or even npm
.
Hi @kentcdodds, I apologize if this isn't the best place to ask this question, but I'm working on a custom scripts toolkit of my own, borrowing heavily from kcd-scripts
, so I thought this might help others who were similarly inspired by this project.
I've started off by re-implementing your linting approach almost directly, and I'm harvesting eslint config from the existing projects I'm supporting, but I'd like to pick your brain about handling a couple various eslintrc wrinkles in my toolkit's config/eslintrc.js
.
First, how would you deal with exporting things like "recommended" configs from plugins? I see you use require.resolve
in your implementation (which, I assume is done to ensure you're exporting config from the toolkit's node_modules
instead of the consuming project's node_modules
), but I'm not quite sure how that might map to usages like this:
extends: [
"eslint:recommended",
"plugin:flowtype/recommended",
"plugin:react/recommended",
"plugin:import/errors"
],
Also, how would you recommend sharing config that's scattered across several .eslintrc
files? For example, In a react
web app with an express
backend, I've got config files with different plugins/rules/etc. for my server
folder (settings for pure non-transpiled node stuff), and my client
folder (react, flow, babel transpiled stuff), and also test
folders (things like jest
or cypress
settings, also inheriting/extending the settings for the source code they target).
Thanks in advance!
Hi,
This is a not bug report. I want to thank you for the toolkit. Previously I used a toolkit similar to this idea from Walmart Labs (don't remember name), but kcd-scripts
is more feature rich.
I implemented a derived version of kcd-scripts
and would like to share a few ideas back here, hoping they are useful for others and hear what they think about them. My derivation is for typescript, but ideas are general.
init
script: Since there are tons of config files, this script generates necessary files in project directory, and creates script entries in package.json
. For example:
.gitattributes
, .gitignore
, .prettierrc.js
are generated.build
, test
, validate
etc. scripts entries are created..gitattributes
, is created as symlink to some base file in kcd-scripts
. So whenever original file is updated, this files acts as updated as well.kcd-scripts
work. However, IDEs are expecting them in project folder to be functional. For example WebStorm looks for .eslintrc
, tsconfig.json
etc. Those files are generated as inheriting from originals, so IDEs can find them, and they are up to date when kcd-scripts
are updated.init
script is automatically executed via scripts.install
entry in package.json, when the module is installed.scripts.precommit
entry to .huskyrc.js
file, because it will be deprecated in next version of `husky``jsdoc2md
script and readme.hbs
template with doctoc
support, which generates API docs both for JavaScript and TypeScript.I didn't publish it yet, because it is still rough.
@kentcdodds, as the creator of original toolkit and experienced user of it, I would like to hear what do you think about those. Are there any caveats/pitfalls or any suggestions?
Kind Regards,
kcd-scripts
version: 0.48.0node
version: v11.3.0npm
(or yarn
) version:import DatePicker from 'react-datepicker'
(see index.js)
What you did:
I am trying to make my own component library for frequently used components, and reducers etc. As long I am doing npm run build
it's all working fine but when I am trying to run npm run build --bundle
it's failing for theumd
-build with the following error:
[umd] [!] (babel plugin) TypeError: @babel/template placeholder "NODE": Property expression of ExpressionStatement expected node to be of a type ["Expression"] but instead got "VariableDeclarator"
[umd] node_modules/react-datepicker/es/index.js
[umd] TypeError: @babel/template placeholder "NODE": Property expression of ExpressionStatement expected node to be of a type ["Expression"] but instead got "VariableDeclarator"
What happened:
After executing the command ./node_modules/.bin/kcd-scripts build --bundle --no-clean --size-snapshot
as found in the paypal/downshift
-repo. I am getting the above mentioned error. I am not sure how I could resolve this.
Reproduction repository:
I have made a small reproducible case of my issue:
https://github.com/weyert/kcd-scripts-issue
Problem description:
I am doing something wrong when using third-party packages but not sure what. I think the problem that this package react-datepicker
is already precompiled.
Suggested solution:
It's be valuable to have a couple reference usages outside of kcd-scripts
itself, since the dogfooded setup is a bit different than most consumers.
The build is currently busted: https://github.com/kentcdodds/kcd-scripts/runs/2604272264?check_suite_focus=true
Not sure what's going on here and I don't have time to look into it right now :(
master
branch failed. π¨I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. Iβm sure you can resolve this πͺ.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here is some links that can help you:
If those donβt help, or if this issue is reporting something you think isnβt right, you can always ask the humans behind semantic-release.
6.4.0
on branch master
cannot be published as it is out of range.Based on the releases published on other branches, only versions within the range >=6.3.0 <6.4.0
can be published from branch master
.
The following commit is responsible for the invalid release:
This commit should be moved to a valid branch with git merge or git cherry-pick and removed from branch master
with git revert or git reset.
A valid branch could be next
.
See the workflow configuration documentation for more details.
Good luck with your project β¨
Your semantic-release bot π¦π
The ifScript
logic sprinkled throughout does not understand scripts defined outside of package.json
, e.g., via nps
.
kcd-scripts
version: 0.36.1node
version: 8.10.0npm
(or yarn
) version: 5.8.0Relevant code or config
const symbol = Symbol();
What you did:
I use the Symbol
in my code, and I expect that it would be transformed into the higher compatibility version in ES5.
What happened:
I can't do this due to the default browsers need to be supported the repo specified can't meet my needs.
Reproduction repository:
Problem description:
I read the source codes of babel-preset-env
and browserslist
and this repo. I make sure that this is because of that browserslist
take the passed query higher priority than the config (package.json or config file). So once you specified the query like the following:
https://github.com/kentcdodds/kcd-scripts/blob/master/src/config/babelrc.js#L13
Suggested solution:
The users like me could not override this in any way. Standing in the perspective of babel-preset-env
or browserslist
, it takes the query in the plugin options higher priority than the config file is reasonable. The kcd-scripts
encapsulate these configurations. So it should treat the browsers list like .babelrc
, if the configuration file exists, use that instead of the built-in.
https://github.com/browserslist/browserslist/blob/master/index.js#L186-L193
kcd-scripts
version: 0.39.1node
version: 10.4.1npm
(or yarn
) version: [email protected]Relevant code or config
{
plugins: [
...
isPreact
? [require.resolve('babel-plugin-transform-react-jsx'), {pragma: 'h'}]
: null,
}
What you did: Build a preact bundle that includes JSX
What happened: JSX gets transformed to just h
instead of React.h
where React is Preact and h is undefined when trying to run the code with the built bundle.
Reproduction repository: https://github.com/donysukardi/kcd-scripts-preact-issue
Problem description: Pragma for Preact build is incorrect
Suggested solution: Update pragma to 'React.h'
instead of just 'h'
kcd-scripts
version: 6.2.3node
version: 12.16.1npm
(or yarn
) version: 6.13.4Relevant code or config
all the config produced by kcd-scripts
What you did:
i introduced kcd-scripts to our team in order to set up a clear repeateable process
What happened:
we now have a consistent means of deploying configuration to our projects, but our team has a weak understanding of what rules we have subjected ourselves to.
Problem description:
trying to understand what eslint and what babel configuration we have is a bit complicated, as there are numerous different configurations that are combined (in eslints case) and a variety of conditionals in the babelrc config generator. eslint in particular has been hard to understand.
Suggested solution:
it would be lovely to have a way to preview the aggregated eslint rules, for example. i'm less sure what could be done about, for example, babel, but that's less difficult to understand.
When having your test script with a set environment (--env=jsdom
) as we have with geniejs
, the pre-commit
script will fail as this will run kcd-scripts test --findRelatedTests
and doesn't take these extra variables into account
"test": "kcd-scripts test --env=jsdom",
https://github.com/kentcdodds/genie/blob/b2aec0a8ea9bf1a0d85fead0427dcb1a1dcee7c8/package.json#L26
kcd-scripts
version: 0.32.1node
version: 8.9.0npm
(or yarn
) version: yarn 1.3.2What you did:
yarn
What happened:
Problem description:
Just having a bunch of warnings, does not seem to affect how a module works.
Suggested solution:
Not sure the solution is needed, but Kent said that he's not using yarn, but npm instead, so I figured it wouldn't hurt to make you're aware of this.
Changes in rollup/rollup-plugin-babel@f8182c6 (v3.0.6) seem to be breaking the rollup build which was previously working fine.
Since this library is not committing lock file, rollup-plugin-babel@^3.0.3
gets resolved to 3.0.6
.
I am getting babelHelpers is not defined
error when trying to run the build artefact.
It seems to be working fine after I remove "babel-plugin-external-helpers"
plugin from .babelrc though.
Reference: rollup/rollup-plugin-babel#228
Note:
This is not an issue per se, but more of a heads-up/unofficial docs for people who encounter the same problem. However this can spark some discussions on how to manage versions of the external (app) and internal (toolbox) dependencies.
Env:
kcd-scripts
^0.42.1:node
: 8.11.3yarn
1.9.4What you did:
Use default pre-commit on CRA based repo.
What happened:
TypeError: environment.teardown is not a function
Problem description:
The issue is realated to the fact that CRA does not allow conflicting Jest versions.
Related issues for some background: jest#6393, jest#5119
Suggested solution:
Add lint-staged
entry in your package.json, ultimately overwriting actions on pre-commit hook, something along these lines
"lint-staged": {
"*.js": [
"yarn format",
"yarn lint",
"git add"
]
},
Without this, formatting is not checked in CI and only applied if the precommit hooks are installed, which is optional
Options:
prettier --list-different
to validate commandkcd-scripts
version: v0.25.1node
version: v7.4npm
(or yarn
) version: v5.4.2Relevant code or config
npm run build
What you did:
Ran this command on Node v7
What happened:
Got an output that did not indicate Node v8 was required.
> [email protected] build /Users/ianjones/Desktop/egghead-dev/kcd-scripts
> node src build
/Users/ianjones/Desktop/egghead-dev/kcd-scripts/src/index.js:18
)
^
SyntaxError: Unexpected token )
at Object.exports.runInThisContext (vm.js:78:16)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:420:7)
at startup (bootstrap_node.js:139:9)
at bootstrap_node.js:535:3
Problem description:
This seems to cause issues with projects that depend on kcd-scripts. Here is a reference:
kentcdodds/generator-kcd-oss#6
It is a more straight-forward error when you experience it in the context of this project. It is likely confusing for someone who would run into this using generator-kdc-oss.
Suggested solution:
Print an error telling the user that Node v8 is required.
We should lock down dependencies. Not sure if you prefer yarn
or npm >=5
.
kcd-scripts
version: 0.14.2node
version: 8.2.1npm
(or yarn
) version: 4.0.5Relevant code or config
What you did:
git commit
What happened:
[22:16:18] Running tasks for **/*.+(js|json|less|css|ts) [started]
[22:16:18] Running tasks for .all-contributorsrc [started]
[22:16:18] Running tasks for .all-contributorsrc [skipped]
[22:16:18] β No staged files match .all-contributorsrc
[22:16:18] C:\Program Files (x86)\Nodist\v-x64\8.2.1\node.exe C:\Users\junyoung\Documents\WebProject\TypeScript\glamorous\node_modules\kcd-scripts\dist\index.js format [started]
[22:16:18] C:\Program Files (x86)\Nodist\v-x64\8.2.1\node.exe C:\Users\junyoung\Documents\WebProject\TypeScript\glamorous\node_modules\kcd-scripts\dist\index.js format [failed]
[22:16:18] β C:\Program could not be found. Try `npm install C:\Program`.
[22:16:18] Running tasks for **/*.+(js|json|less|css|ts) [failed]
[22:16:18] β C:\Program could not be found. Try `npm install C:\Program`.
C:\Program could not be found. Try `npm install C:\Program`.
Suggested solution:
Well, let's wait the response in lint-staged/lint-staged#292
or fix https://github.com/kentcdodds/kcd-scripts/blob/master/src/config/lintstagedrc.js
I first issued this to the @testing-library/react but after debugging I found out this issue belongs to this project.
Looks like it's caused by https://github.com/kentcdodds/kcd-scripts/blob/master/src/config/rollup.config.js#L44. I don't know the reasoning behind this.
testing-library/react-testing-library#797
I noticed that the generated UMD files has incorrect spelling of ReactDOM. The "DOM" part is misspelled as "Dom".
Steps:
How did I find this? Our company are using a legacy build system and we rely on globals everywhere and we are on way to migrate from Enzyme to this lib.
node
version: 10.10.0npm
(or yarn
) version: 6.0.0Relevant code or config
npm run precommit
Problem description:
I'm working on a fork of kcd-scripts for my own company's purposes and while testing the lintstagedrc.js file failes on Windows. Probably has to do with #8 or is very similar. I also noticed this when working on React-Testing-Library when I went to commit, again lintstagedrc.js fails.
Unfortunately I'm not versed enough in the fs and path operators to figure out how to change \ for /. Unless we write a dirty method to check for win32 and do a global replace on the path string, tranding slashes. But I don't know what other problems might arise from that.
next
branch failed. π¨I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. Iβm sure you can resolve this πͺ.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the next
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here is some links that can help you:
If those donβt help, or if this issue is reporting something you think isnβt right, you can always ask the humans behind semantic-release.
6.1.0
on branch next
cannot be published as it is out of range.Based on the releases published on other branches, only versions within the range >=6.3.0
can be published from branch next
.
The following commit is responsible for the invalid release:
This commit should be moved to a valid branch with git merge or git cherry-pick and removed from branch next
with git revert or git reset.
A valid branch could be master
or next
.
See the workflow configuration documentation for more details.
Good luck with your project β¨
Your semantic-release bot π¦π
I'm trying to use this module to replace babel in the below project but getting errors. Any help is appreciated.
Git repo : https://github.com/chandanrjit/react-webpack-boilerplate
usage:
{"presets": ["kcd-scripts/babel"]}
ERROR in ./src/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module 'kcd-scripts/babel' from 'C:\workspace\code\research\react-webpack-boilerplate'
at Function.resolveSync [as sync] (C:\workspace\code\research\react-webpack-boilerplate\node_modules\resolve\lib\sync.js:81:15) at resolveStandardizedName (C:\workspace\code\research\react-webpack-boilerplate\node_modules\@babel\core\lib\config\files\plugins.js:101:31)
Hi @kentcdodds!
Thanks for the scripts, very cool project. I've been looking for something like this for a few months and how happy I was to find this. π
I have stumbled upon a little issue. The scoped packages are getting unconventional build artifacts.
@namespace/package-name
is getting a file structure that reflects the name /dist/@namespace/package-name.umd.js
What do you think about converting @namespace/package-name
-> namespace-package-name
or maybe even dropping the namespace
if it is present?
Please feel free to close this if you don't find it relevant or necessary. I'm willing to send a quick PR if this makes sense.
kcd-scripts
version 10.1.1
/11.0.0
:node
version: N/Anpm
(or yarn
) version: N/ARelevant code or config
npm i kcd-scripts@latest
What you did:
Tried installing the latest version after the release notes for 10.1.0
told me about the accidental breaking changes and the reversion.
What happened:
Version 10.1.1.
is installed instead of version 11.0.0
.
Reproduction repository:
N/A
Problem description:
I assume it's a mistake that kcd-scripts@latest
is pointing to 10.1.1
in NPM, right? https://www.npmjs.com/package/kcd-scripts?activeTab=versions
Suggested solution:
Push the latest tag to 11.0.0
.
kcd-scripts
version: 1.8.0node
version: 10.16.3npm
(or yarn
) version: 6.11.3Relevant code or config
# .prettierrc.toml
semi = true
singleQuote = false
What you did:
Added a local .prettierrc.toml
and ran format.
What happened:
The local configuration was not respected.
Problem description: I have a local .prettierrc.toml
and it is not being respected.
Suggested solution: Prettier uses cosmiconfig
for configuration file support. Leverage cosmiconfig when looking for local configuration. It also handles inspecting package.json
as well. I suspect you could leverage this with all the different commands eliminating the need to do the search yourself.
kcd-scripts
version: 1.2.1node
version: 10.11.0npm
(or yarn
) version: npm 6.9.0Relevant code or config
"scripts": {
"test": "kcd-scripts test --config=jest.config.js"
},
What you did:
npm run test
What happened:
Error: You should add @babel/runtime as dependency to your package. It will allow reusing "babel helpers" from node_modules rather than bundling their copies into your files.
at Object.<anonymous> (/Users/bmonro001/Code/react-svelte/node_modules/kcd-scripts/dist/config/babelrc.js:33:9)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/Users/bmonro001/Code/react-svelte/node_modules/kcd-scripts/dist/config/index.js:4:10)
at Module._compile (internal/modules/cjs/loader.js:689:30)
Reproduction repository:
https://github.com/benmonro/react-svelte/tree/bug/kcd-script-error
Problem description:
why do i need to install @babel/runtime as a (non dev) dependency just to run tests?
Suggested solution:
have kcd-scripts not require that dep.
kcd-scripts
version: 0.37.0node
version: 0.8.4npm
version: 0.5.3windows
version: 10While working on the PR for cypress-testing-library
, I thought I'd enable the pre-commit hook. So I added the .opt-in
file and added the pre-commit
text to it. Then I did the git commit (both SourceTree and command line)
Running tasks for README.md [started]
Running tasks for README.md [failed]
β .\node_modules\doctoc\doctoc.js could not be found. Try `npm install .\node_modules\doctoc\doctoc.js`.
doctoc.js
does exist in the node_modules folder.
resolveBin
:
Lines 21 to 44 in bd3d642
It's responsible for taking a module name (like eslint
) and getting a path to the executable binary. If the path to the executable is the same as the one that's in the $PATH
environment variable (using which
), then we can return the raw binary name itself and execute a script with that, otherwise we'll return the full path so it's executed with the full path (because it's not available in $PATH
presumably.
This is useful because if the user sees the script we run (which they do in some situations) then the script will be shorter.
It works on linux systems right now, but apparently the result of which.sync
is to a file ending in .CMD
and isn't a symlink (so the realpathSync
doesn't resolve it to the binary path).
So we need to find a package that will do this for us (I already tried resolve-bin
and it didn't work the way I want it to) or fix this function up to make it work for windows as well as linux.
Anyone wanna help out?
kcd-scripts
version: 0.37.0node
version: 9.11.1npm
version: 5.3.0What you did:
Create fresh copy of create-react-app
install kcd-scripts as dev dependency
Add lint script to package.json
"lint": "kcd-scripts lint"
What happened:
Cannot find module '@ljharb/eslint-config'
Referenced from: C:\Node\test-project\node_modules\array-includes\.eslintrc
Error: Cannot find module '@ljharb/eslint-config'
Referenced from: C:\Node\test-project\node_modules\array-includes\.eslintrc
at ModuleResolver.resolve (C:\Node\test-project\node_modules\kcd-scripts\node_modules\eslint\lib\util\module-resolve
r.js:74:19)
Reproduction repository:
I created a fresh copy of react-react-app
npx create-react-app test-project
No need for a production repo
Problem description:
I don't see @ljharb/eslint-config
referenced in the internal eslint config for kcd-scripts so I don't know where this error is coming from. I can only assume it has something to do with array-includes package but I'm not 100%
Suggested solution:
I do not have a suggested solution at this time.
kcd-scripts
version: 0.27.2node
version: 9.3.0yarn
version: 1.3.2Relevant code or config
collectCoverageFrom: ['src/**/*.js'],
testMatch: ['**/__tests__/**/*.js'],
testPathIgnorePatterns: [...ignores],
coveragePathIgnorePatterns: [...ignores, 'src/(umd|cjs|esm)-entry.js$'],
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
Problem description: This isn't a huge problem since the benefit of kcd-scripts
is the ability to overwrite options. But, given the high number of typescript, it would be nice to not have to overwrite the same options every time.
Suggested solution: Before creating a PR, I wanted to pose the question to see what others thought. Is addin *.ts
and *.jsx
to jest.config.js a worthy thought?
kcd-scripts
version: "0.38.1"node
version: v8.6.0npm
(or yarn
) version: 5.5.1Relevant code or config
What you did:
git commit -m "..."
What happened:
husky > npm run -s precommit (node v8.6.0)
Could not parse lint-staged config.
Error: Cannot find module './node_modules/kcd-scripts/dist/config/lintstagedrc.js'
Please make sure you have created it correctly.
See https://github.com/okonet/lint-staged#configuration.
husky > pre-commit hook failed (add --no-verify to bypass)
...
ls -la ./node_modules/kcd-scripts/dist/config/lintstaged.config.js
-rw-r--r-- 1 xxx zzz 707 May 21 12:05 ./node_modules/kcd-scripts/dist/config/lintstaged.config.js
Reproduction repository:
https://github.com/stereobooster/react-precious-image
Problem description:
lint-staged
can not resolve path to the config properly
Suggested solution:
provide full path to the config (starting from the root)
kcd-scripts
version: "kcd-scripts": "^7.5.3"
node
version: v14.16.0
npm
(or yarn
) version: [email protected]
Make change to code and create commit.
kcd-scripts test --findRelatedTests
hangs. Jest is passed --watch
option due to SCRIPTS_PRE-COMMIT
dropping somewhere in execution.
@testing-library/dom-testing-library
@testing-library/react-testing-library
@testing-library/eslint-plugin-jest-dom
Some debug logs tracing SCRIPTS_PRE-COMMIT
environment variable.
Lines 84 to 92 in 5d34c54
83 | console.log(`SCRIPTS_PRE-COMMIT ${getEnv()['SCRIPTS_PRE-COMMIT']}`);
| ^^^ logs "SCRIPTS_PRE-COMMIT true" β
kcd-scripts/src/scripts/pre-commit.js
Lines 22 to 25 in 5d34c54
22 | console.log('SCRIPTS_PRE-COMMIT', process.env['SCRIPTS_PRE-COMMIT']);
| ^^^ logs "SCRIPTS_PRE-COMMIT true" β
kcd-scripts test
run by lint-staged
does not have same environment variables as processes spawned before.
kcd-scripts/src/scripts/test.js
Lines 25 to 26 in 5d34c54
24 | console.log('SCRIPTS_PRE-COMMIT', process.env['SCRIPTS_PRE-COMMIT']);
| ^^^ logs "SCRIPTS_PRE-COMMIT undefined" β
25 | console.log('watch', watch);
| ^^^ logs "watch [ '--watch' ]" β
There's work-around to commit with CI=true
.
My guess is that lint-staged
or husky
is not handling environment variables correctly. But I wonder why no one else is running into this.
Sometimes I like to pipe my Node programs through Webpack, mainly so I have an isomorphic and consistent build tooling setup, including watching scripts, using Babel even on some node_modules, use custom loaders, minify/obfuscate code, etc. We could support that here: https://github.com/kentcdodds/kcd-scripts/blob/63caff0/src/config/babelrc.js#L12-L14
kcd-scripts
version: 7.5.3node
version: 10.22.0npm
(or yarn
) version: yarn 1.22.5Relevant code or config
"eslintConfig": {
"extends": "./node_modules/kcd-scripts/eslint.js",
...
},
"husky": {
"hooks": {
"pre-commit": "kcd-scripts pre-commit"
}
},
What you did:
Trying to make a commit on the Downshift
library I get an error when kcd-scripts lint
is running.
What happened:
β― git commit -m "fix: test"
husky > pre-commit (node v10.22.0)
β Preparing...
β Running tasks...
β No staged files match README.md [SKIPPED]
β― kcd-scripts lint [FAILED]
β kcd-scripts format
β kcd-scripts lint [FAILED]
βΌ kcd-scripts test --findRelatedTests
β Skipped because of errors from tasks. [SKIPPED]
β Reverting to original state because of errors...
β Cleaning up...
β kcd-scripts lint:
Oops! Something went wrong! :(
ESLint: 7.15.0
Error: package.json Β» ./node_modules/kcd-scripts/eslint.js Β» /Users/jorge.moya/dev/downshift/node_modules/kcd-scripts/node_modules/eslint-config-kentcdodds/jest.js:
Environment key "jest/globals" is unknown
at Object.keys.forEach.id (/Users/jorge.moya/dev/downshift/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:173:23)
at Array.forEach (<anonymous>)
at ConfigValidator.validateEnvironment (/Users/jorge.moya/dev/downshift/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:167:34)
at ConfigValidator.validateConfigArray (/Users/jorge.moya/dev/downshift/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:317:18)
at CascadingConfigArrayFactory._finalizeConfigArray (/Users/jorge.moya/dev/downshift/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:493:23)
at CascadingConfigArrayFactory.getConfigArrayForFile (/Users/jorge.moya/dev/downshift/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:299:21)
at FileEnumerator._iterateFilesWithFile (/Users/jorge.moya/dev/downshift/node_modules/kcd-scripts/node_modules/eslint/lib/cli-engine/file-enumerator.js:365:43)
at FileEnumerator._iterateFiles (/Users/jorge.moya/dev/downshift/node_modules/kcd-scripts/node_modules/eslint/lib/cli-engine/file-enumerator.js:346:25)
at FileEnumerator.iterateFiles (/Users/jorge.moya/dev/downshift/node_modules/kcd-scripts/node_modules/eslint/lib/cli-engine/file-enumerator.js:296:59)
at iterateFiles.next (<anonymous>)
husky > pre-commit hook failed (add --no-verify to bypass)
Reproduction repository: https://github.com/downshift-js/downshift/
I wasn't sure if it was best to report this issue here on in eslint-config-kentcdodds
. Let me know if I should move the issue somewhere else, thank you.
We no longer need the lint-staged
config require cache hack (https://github.com/kentcdodds/kcd-scripts/blob/1fa8622/src/scripts/precommit/lint-staged.js#L16-L20) since it supports --config
CLI flag since https://github.com/okonet/lint-staged/releases/tag/v4.3.0.
kcd-scripts
version: 0.25.1node
version: 8.6.0npm
(or yarn
) version: yarn 1.1.0OS
: Mac OS Sierra (10.12.6)What you did:
yarn add -D kcd-scripts
yarn lint:js
-> kcd-scripts lint
What happened:
Basically a series of errors saying that some plugin or config is not found, after I run the lint command.
Problem description:
I'm trying to move my existing project to use CRA for production build (codesplitting, etc.) and kcd-scripts for dev (linting, prettier, precommit) to avoid config bloat and hide all of the webpack + babel mess. CRA was no problem, but as I moved to dev workflow, trying to run kcd-scripts lint resulted in missing some sort of plugin or config. After doing yarn add -D the_missing_thing
and repeating the lint command it spat out anther missing dep and so on. I've continued installing more and more of these and each time kcd-scripts lint
took more and more time to run.
I'm currently on my 10th missing module and I don't think it should be this way :)
The whole point of the toolkits is to encapsulate dependencies and I get this:
Suggested solution:
I think that eslint
's module-resolver is scanning all modules in node_modules and pulling their eslint-configs and then it throws when it doesn't find something. But I'm not sure, it's a wild guess based from the error and I'm pretty sure kcd-scripts does not need stuff like cssnano
to run.
TBH I don't know why I even have that in my dependencies, but it's node - not surprising:)
Thank you for your work @kentcdodds, I really enjoy all of the OSS things you do.
kcd-scripts
version: 1.5.2node
version: 12.6.0npm
(or yarn
) version: Yarn 1.12.1Relevant code or config
I fave the following script in my package.json "lint": "kcd-scripts lint --config .eslintrc.js --ignore-path .eslintignore"
My eslintrc.js file contains:
module.exports = {
extends: './node_modules/kcd-scripts/eslint.js',
rules: {
'import/extensions': [
'error',
{
json: 'always',
js: 'never',
css: 'off',
jpg: 'always',
png: 'always',
JPG: 'always',
},
],
'react/prop-types': 'warn',
},
}
What you did:
Ran script yarn run lint
What happened:
The result is in a eslint config validator error Environment key "jest/globals" is unknown
Jeffs-Air:SpacePoints jeffbaumgardt$ yarn run lint
yarn run v1.12.1
$ kcd-scripts lint --config .eslintrc.js --ignore-path .eslintignore
Error: .eslintrc.js Β» ./node_modules/kcd-scripts/eslint.js Β» /Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint-config-kentcdodds/jest.js:
Environment key "jest/globals" is unknown
at /Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint/lib/shared/config-validator.js:169:19
at Array.forEach (<anonymous>)
at validateEnvironment (/Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint/lib/shared/config-validator.js:163:30)
at validateConfigArray (/Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint/lib/shared/config-validator.js:334:9)
at CascadingConfigArrayFactory._finalizeConfigArray (/Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:392:13)
at CascadingConfigArrayFactory.getConfigArrayForFile (/Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:248:21)
at FileEnumerator._iterateFilesRecursive (/Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint/lib/cli-engine/file-enumerator.js:400:49)
at _iterateFilesRecursive.next (<anonymous>)
at FileEnumerator.iterateFiles (/Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint/lib/cli-engine/file-enumerator.js:254:49)
at iterateFiles.next (<anonymous>)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Reproduction repository:
https://github.com/JeffBaumgardt/testingCRA-KCDScripts
This is a fresh install of CRA and kcd-scripts only files added are the .eslintignore and .eslintrc.js files. Added lint script to package.json
Problem description:
The config validator for eslint is complaining about the env flag for jest/globals. I'm not sure why as this is a valid flag per the eslint-plugin-jest
plugin. I've looked around and have not been able to find any information pertaining to this issue. On eslint-plugin-jest, eslint, or eslint-config-kentcdodds.
If this issue is better placed in the eslint-config-kentcdodds repo I will be happy to add it there.
Suggested solution:
I don't have any good ideas at the moment.
I suggest using babel's loose
mode by default, it allows you to ship quite less bytes of code to the end users and truth to be told, you shouldn't really miss most of default fully spec-compliant behaviours.
shared-tsconfig
allow importing modules from src
per module name.
kcd-scripts/shared-tsconfig.json
Line 13 in 5c69945
The IDE picks this up and suggests using non-relative imports.
kcd-scripts build
does not support the import from baseUrl
and resulting build is corrupt.
Remove the baseURL
.
kcd-scripts
version: 1.11.0node
version: 10npm
(or yarn
) version: yarn 1.19.2Relevant code or config
What you did:
$ kcd-scripts build --no-clean
What happened:
yarn build:main
yarn run v1.19.2
$ kcd-scripts build --no-clean
error: unknown option '--no-clean'
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Reproduction repository:
https://github.com/testing-library/react-testing-library
Problem description:
@babel/[email protected]
no longer silently ignores excess args (babel/babel#10698)
Suggested solution:
Pin @babel/cli
to 7.7.0
in short term and use proper arg parsing and forwarding in the long term
kcd-scripts
version: 0.48.0node
version: v11.3.0npm
(or yarn
) version: 6.4.1I would like to be able to debug unit tests and indirectly my library code from Visual Studio Code only currently I am not able to get it working easily. I think it might be related to the use of cross-spawn. The main problem is that Visual Studio passed --inspect-brk=33548
argument to the node while run-script
expects the script name. E.g. kcd-scripts --inspect-brk=33548 test
How are you currently debugging the code base? E.g. downshift?
kcd-scripts
version: 6.6.0
node
version: 14.14.0
npm
version: 6.14.8
Relevant code or config
$ kcd-scripts build --out-dir .
What you did:
Run npm run build
in the root of the project
What happened:
src/__tests__/gatsby-node.js
was deleted
Reproduction repository:
https://github.com/MichaelDeBoey/gatsby-plugin-pinterest/tree/support-pluginOptionsSchema
Problem description:
When implementing gatsby-uc/gatsby-plugin-pinterest#15 and running npm run build
or npm run validate
in the root of the project, src/__tests__/gatsby-node.js
was deleted.
Suggested solution:
Investigation needed π€
I'm getting this error on the most recent version when I try to run tests
This issue seems to indicate it can be fixed by updating @babel/preset-env
and @babel/core
Hi, I wanted to start working on testing-library/dom-testing-library#494 but it seems like kcd-scripts
doesn't support transpilation of TypeScript files.
kcd-scripts
version: 5.6.1node
version: 12.11.0npm
(or yarn
) version: N/AWhat you did:
I cloned https://github.com/testing-library/dom-testing-library, renamed src/index.js
to src/index.ts
and started working on enabling TS support.
Changing input file was easy:
cross-env BUILD_INPUT=src/index.ts kcd-scripts build
I've added typescript
and @babel/preset-typescript
dependencies and babel config:
// babel.config.js
module.exports = {
presets: ['kcd-scripts/babel', '@babel/preset-typescript'],
}
This is where the issue comes. Because kcd-scripts
doesn't support overriding rollup plugins, I can't add extensions: ['.js, '.ts']
to rollupBabel
and nodeResolve
plugins. Also, I need to use runtimeHelpers: true
for some reason, but I use custom babel config so this line is stopping me as well:
kcd-scripts/src/config/rollup.config.js
Line 155 in 9f75a86
Problem description:
I need to customize some plugins in rollup configuration.
Suggested solutions (pick one):
runtimeHelpers: true
under some condition. A flag maybe? Or automatic detection based on input file extension?This is how I visualize 3rd option:
// kcd-scripts' rollup.config.js
const builtinPlugins = {babel: rollupBabel(...), resolve: nodeResolve(...), ...};
module.exports = {
input,
output,
...,
plugins: Object.values(builtinPlugins),
builtinPlugins,
}
// custom usage rollup.config.js
const rollupConfig = require('kcd-scripts/dist/config/rollup.config')
const rollupBabel = require('rollup-plugin-babel')
rollupConfig.builtinPlugins.babel = rollupBabel({
extensions: ['.js', '.ts'],
runtimeHelpers: true,
}),
rollupConfig.plugins = Object.values(builtinPlugins)
module.exports = rollupConfig
kcd-scripts
version: 6.1.0node
version: 12 & 14npm
(or yarn
) version: latestRelevant code or config
testing-library/testcafe-testing-library#167
Validate
What you did
Dependabot tried to update to 6.1.0
What happened:
Something broke between 6.0.1 & 6.1.0 not sure what but validate is breaking on testcafe testing library.
Reproduction repository:
testing-library/testcafe-testing-library#167
Problem description:
Suggested solution:
Looks like you support a Rollup build. Would you also consider adding support for Webpack?
For extensibility, could take inspiration from https://github.com/timarney/react-app-rewired.
kcd-scripts
version: 7.5.3node
version: 12.20.0npm
(or yarn
) version: 6.14.8Relevant code or config
export function createFunc1() {
function func() {
}
return func
}
export function createFunc2() {
function func() {
}
const name = func.name // not returned, just used
return func
}
What you did:
Run kcd-scripts build
What happened:
The output is
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createFunc1 = createFunc1;
exports.createFunc2 = createFunc2;
function createFunc1() {
return function () {};
}
function createFunc2() {
function func() {}
func.name; // not returned, just used
return func;
}
Reproduction repository:
Problem description:
The name of the function returned in createFunc1
gets removed thanks to babel-plugin-minify-dead-code-elimination
. This is causing me problems in a node package (specifically a testing library) where the name gets removed and consequently does not appear in stack traces which hurts debugability when things go wrong.
I can understand the desire to remove this when building for browsers (reduced bundle size), but I don't personally see many advantages to this for a node/test package.
Suggested solution:
There is an option to keep function names in the plugin, so we could set that the be true and keep the rest of the functionality. We could use the isTest
flag to conditionally set the option for tests only.
Similarly, we could use the isTest
flag to remove the plugin all together for tests.
Either solution would suffice for my issue. I'm also happy to submit the PR for this change if you agree with it and can advise me which approach is your preference.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.