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

Convert to ESM #1391

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Convert to ESM #1391

wants to merge 2 commits into from

Conversation

wmertens
Copy link
Contributor

@wmertens wmertens commented Apr 1, 2024

No description provided.

@wmertens
Copy link
Contributor Author

wmertens commented Apr 1, 2024

The failing test is trying to import the esm module as cjs which should't work.

@raineorshine
Copy link
Owner

The CJS test can be removed since it will no longer be supported.

@wmertens
Copy link
Contributor Author

wmertens commented Apr 4, 2024

All good now 😃

Comment on lines +12 to +15
# turn off stop on error
set +e
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify why this is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC this was causing the verdaccio shutdown to fail. Not sure any more :-/

test/e2e.sh Outdated

# turn off stop on error
set +e

exit_status=$?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be the first line in the trap function to capture the exit code correctly. I'm seeing "Done" printed instead of "Error" when I fail the test intentionally.

package.json Outdated
"lint:src": "eslint --cache --cache-location node_modules/.cache/.eslintcache --ignore-path .gitignore --report-unused-disable-directives .",
"prepare": "src/scripts/install-hooks && test/bun-setup.sh",
"prepublishOnly": "npm run build",
"prettier": "prettier . --check",
"test": "npm run test:unit && npm run test:e2e",
"test:unit": "mocha test test/package-managers/*",
"test:unit": "vitest test/package-managers/*",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've accidentally dropped the main test suite in the test directory. Once enabled, I'm seeing: process.chdir() is not supported in workers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how did I drop it? Not sure why that message though.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mocha test test/package-managers/* specifies two paths: ./test and ./test/package-managers/*. This edit removes the ./test path from the test:unit script (which is the main test suite for the project).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah maybe because it always used chdir and vitest uses workers?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process.chdir is only used in getAllPackages.test.ts, and it appears to be a remnant of some local testing that another developer did. The tests pass without it, so I removed it in 688c07f.

You can either rebase on main, or cherry pick that commit if you want to get the tests working before dealing with the merge conflicts.

@raineorshine
Copy link
Owner

@wmertens Just checking in to see if you have an update.

@wmertens
Copy link
Contributor Author

I'm trying to rebase but

npm ERR! command bash -c node install.js
npm ERR! Failed to find package "@oven/bun-linux-x64". You may have used the "--no-optional" flag when running "npm install".
npm ERR! Failed to find package "@oven/bun-linux-x64-baseline". You may have used the "--no-optional" flag when running "npm install".

@raineorshine
Copy link
Owner

Sorry about that! I got the same thing, but I was hoping it would work once the lock file was updated. It installs fine in ci mode.

Try npm install -f bun. That worked for me. I'll circle back with a better fix soon.

@wmertens
Copy link
Contributor Author

:( doesn't work, and when I try to install oven, it gets worse:

1223 $ npm i -f bun @oven/bun-linux-x64 @oven/bun-linux-x64-baseline
npm WARN using --force Recommended protections disabled.
npm ERR! code 1
npm ERR! path /home/wmertens/Projects/npm-check-updates/node_modules/bun
npm ERR! command failed
npm ERR! command bash -c node install.js
npm ERR! Failed to find package "@oven/bun-linux-x64". You may have used the "--no-optional" flag when running "npm install".
npm ERR! Failed to install package "@oven/bun-linux-x64" using "npm install". Error: ENOENT: no such file or directory, rename '/tmp/bun-IZCrJ9/node_modules/@oven/bun-linux-x64' -> 'node_modules/@oven/bun-linux-x64'
npm ERR!     at Object.renameSync (node:fs:1032:11)
npm ERR!     at rename (/home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:202:21)
npm ERR!     at installBun (/home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:388:23)
npm ERR!     at /home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:360:7
npm ERR!     at Generator.next (<anonymous>)
npm ERR!     at /home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:41:59
npm ERR!     at new Promise (<anonymous>)
npm ERR!     at __async (/home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:27:51)
npm ERR!     at requireBun (/home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:341:10)
npm ERR!     at /home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:332:22 {
npm ERR!   errno: -2,
npm ERR!   code: 'ENOENT',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/tmp/bun-IZCrJ9/node_modules/@oven/bun-linux-x64',
npm ERR!   dest: 'node_modules/@oven/bun-linux-x64'
npm ERR! }
npm ERR! Failed to find package "@oven/bun-linux-x64-baseline". You may have used the "--no-optional" flag when running "npm install".
npm ERR! Failed to install package "@oven/bun-linux-x64-baseline" using "npm install". Error: EXDEV: cross-device link not permitted, rename '/tmp/bun-4Pgjla/node_modules/@oven/bun-linux-x64-baseline' -> 'node_modules/@oven/bun-linux-x64-baseline'
npm ERR!     at Object.renameSync (node:fs:1032:11)
npm ERR!     at rename (/home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:202:21)
npm ERR!     at installBun (/home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:388:23)
npm ERR!     at /home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:360:7
npm ERR!     at Generator.next (<anonymous>)
npm ERR!     at /home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:41:59
npm ERR!     at new Promise (<anonymous>)
npm ERR!     at __async (/home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:27:51)
npm ERR!     at requireBun (/home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:341:10)
npm ERR!     at /home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:332:22 {
npm ERR!   errno: -18,
npm ERR!   code: 'EXDEV',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/tmp/bun-4Pgjla/node_modules/@oven/bun-linux-x64-baseline',
npm ERR!   dest: 'node_modules/@oven/bun-linux-x64-baseline'
npm ERR! }
npm ERR! Error: Failed to install package "bun"
npm ERR!     at /home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:336:11
npm ERR!     at Generator.throw (<anonymous>)
npm ERR!     at rejected (/home/wmertens/Projects/npm-check-updates/node_modules/bun/install.js:36:27)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

npm ERR! A complete log of this run can be found in: /home/wmertens/.npm/_logs/2024-04-25T20_49_55_667Z-debug-0.log

@wmertens
Copy link
Contributor Author

I tried pushing without updating the npm lock but then the markdown lint complains about readme

@raineorshine
Copy link
Owner

Okay. I think since bun is not very cross-platform compatible, I will move it into a separate optional test script, and remove it from devDependencies.

@raineorshine
Copy link
Owner

raineorshine commented Apr 26, 2024

Okay, I've offloaded the bun tests to a separate script in bc18c92. You no longer need bun to npm install and run the unit tests.

uses same build setup as vite; mocha doesn't like ESM
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

2 participants