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

revert compatibility #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

lamweili
Copy link

@lamweili lamweili commented Jul 25, 2023

In commit 9f62693, let was used.

word-wrap/index.js

Lines 9 to 10 in 207044e

let lastCharPos = str.length - 1;
let lastChar = str[lastCharPos];

However, the package.json specifies "node": ">=0.10.0" compatibility.

"node": ">=0.10.0"

This resulted in the following errors for older Node.js:

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

Thus, we should change let to var to maintain compatibility for ^1.x.x in adherence to semver.
If compatibility needs to be upgraded, it should be the next major semver (^2.x.x) release.

@doowb
Copy link
Collaborator

doowb commented Jul 25, 2023

Thanks @lamweili . Should const also be replaced?

@lamweili
Copy link
Author

lamweili commented Jul 25, 2023

@doowb, const is good according to node.green.
My GitHub actions, which test older Node.js (v4) for compatibility issues, didn't flag any errors.

@DmitryZ-outten
Copy link

@lamweili Thanks! Have the same issue with node v4

@bahamat
Copy link

bahamat commented Jul 27, 2023

I'm having a problem with let on node 4 as well:

21:12:26    let lastCharPos = str.length - 1;
21:12:26    ^^^
21:12:26  
21:12:26  SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

If I edit index.js by hand after installing and add 'use strict'; at the beginning of the file then I don't get this error.

@lamweili
Copy link
Author

lamweili commented Jul 27, 2023

Although we might not use word-wrap explicitly, it is used by dependencies such as eslint.
(eslint@>=2 <=7.0.0-alpha.3 > optionator@^0.8 > word-wrap@~1.2.3)

Editing the index.js by hand is a workaround but might be overridden by npm.

It will be good to quickly patch it back to restore compatibility instead of all dependencies changing major semver.

@bahamat
Copy link

bahamat commented Jul 27, 2023

Can confirm, I'm hitting this because of eslint.

@bahamat
Copy link

bahamat commented Jul 27, 2023

For clarification, I wasn’t suggesting editing index.js as a workaround. But if the maintainer wants to keep let, then use strict might be an alternative.

@lamweili
Copy link
Author

lamweili commented Aug 3, 2023

@doowb, any chance of merging and releasing it soon?

@lamweili
Copy link
Author

It seems like @doowb is busy. How about @jonschlinkert?

@lamweili
Copy link
Author

lamweili commented Apr 5, 2024

Bump! @doowb @jonschlinkert

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

Successfully merging this pull request may close these issues.

None yet

5 participants