Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Won't work for sub functions #18

Open
falsandtru opened this issue Mar 27, 2021 · 16 comments
Open

Won't work for sub functions #18

falsandtru opened this issue Mar 27, 2021 · 16 comments

Comments

@falsandtru
Copy link

falsandtru commented Mar 27, 2021

Now the sub functions such as assert.doesNotThrow won't be removed. Probably this is a bug on the upstream.

@falsandtru
Copy link
Author

@twada Is this working on your projects?

@falsandtru
Copy link
Author

falsandtru commented Mar 27, 2021

I found this is caused by the update of espurify.

@twada
Copy link
Member

twada commented Mar 27, 2021

@falsandtru Oh thank you for reporting. I'm going to investigate this issue.

@falsandtru
Copy link
Author

Thanks.

@twada
Copy link
Member

twada commented Mar 27, 2021

@falsandtru I cannot reproduce the case since assert.doesNotThrow still removed properly. Would you make a small reproduction case?

#19

@falsandtru
Copy link
Author

Did you test after clean install?

@twada
Copy link
Member

twada commented Mar 27, 2021

yes

$ mkdir pd-unassert
$ cd pd-unassert
$ npm init -y
Wrote to /Users/takuto/work/pd-unassert/package.json:

{
  "name": "pd-unassert",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}


$ npm install --save-dev unassert-cli
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

+ [email protected]
added 43 packages from 130 contributors and audited 43 packages in 3.71s

9 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

$ cat <<EOT >> prod.js
heredoc> const assert = require('assert');
heredoc> function fail() {
heredoc>   throw new Error('fail');
heredoc> }
heredoc> assert.doesNotThrow(function () {
heredoc>   fail();
heredoc> });
heredoc> EOT
$ cat prod.js
const assert = require('assert');
function fail() {
  throw new Error('fail');
}
assert.doesNotThrow(function () {
  fail();
});
$ npx unassert prod.js
function fail() {
    throw new Error('fail');
}
$ 

@falsandtru
Copy link
Author

falsandtru commented Mar 27, 2021

Indeed. I couldn't make a simple repro. FYI, the leaked assertions are this: falsandtru/pjax-api@265f135. Since they are few (almost all assertions are removed), this bug is stateful. Can you release the updated version at first?

@falsandtru
Copy link
Author

falsandtru commented Mar 28, 2021

The current repro:

  1. Clone https://github.com/falsandtru/pjax-api
  2. Checkout 4bf593c1d2350ca332f2e943f03ec99b8d4046bf
  3. Run npm i
  4. Run gulp dist
  5. See dist/pjax-api.js

@twada
Copy link
Member

twada commented Mar 29, 2021

@falsandtru Thank you for your repro case! I'm going to find the root cause and fix it.

@falsandtru
Copy link
Author

Since the current espurify is broken, can you release v2.0.1 as the latest?

@twada
Copy link
Member

twada commented Mar 29, 2021

No, no, espurify is not broken but unssert do. I'll cut some bugfix releases ASAP.

@falsandtru
Copy link
Author

OK.

@twada
Copy link
Member

twada commented Mar 29, 2021

Since the current espurify is broken, can you release v2.0.1 as the latest?

First I've tagged [email protected] as latest.

@falsandtru
Copy link
Author

That's what I intended. Thanks.

twada added a commit to estools/espurify that referenced this issue Mar 29, 2021
twada added a commit to estools/espurify that referenced this issue Mar 29, 2021
@twada
Copy link
Member

twada commented Mar 29, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants