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

feat: remove shebang when executing the code via vite-node #1224

Merged
merged 3 commits into from May 6, 2022

Conversation

togami2864
Copy link
Contributor

fix #1175

@netlify
Copy link

netlify bot commented May 1, 2022

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit 57bb94b
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/6274f61873631b00088858dc
😎 Deploy Preview https://deploy-preview-1224--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

packages/vite-node/src/cli.ts Outdated Show resolved Hide resolved
@togami2864
Copy link
Contributor Author

The PR for vite is merged!! I'll rebase main branch after the next vite release and update this PR.

@patak-dev
Copy link
Member

Thanks for the PR in vite @togami2864! vite@2.9.8 has been released with it.

packages/vite-node/src/client.ts Outdated Show resolved Hide resolved
@@ -178,7 +178,7 @@ export class ViteNodeRunner {
})

// add 'use strict' since ESM enables it by default
const fn = vm.runInThisContext(`'use strict';async (${Object.keys(context).join(',')})=>{{${transformed}\n}}`, {
const fn = vm.runInThisContext(`'use strict';async (${Object.keys(context).join(',')})=>{{${transformed.replace(/^\#\!.*/, '')}\n}}`, {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const fn = vm.runInThisContext(`'use strict';async (${Object.keys(context).join(',')})=>{{${transformed.replace(/^\#\!.*/, '')}\n}}`, {
const fn = vm.runInThisContext(`'use strict';async (${Object.keys(context).join(',')})=>{{${transformed.replace(/^\#\!.*/, s => ' '.repeat(s.length))}\n}}`, {

To avoid index changes.

@antfu antfu changed the title feat: enable to remove shebang when executing the code via vite-node feat: remove shebang when executing the code via vite-node May 6, 2022
@antfu antfu merged commit 5dcfea7 into vitest-dev:main May 6, 2022
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.

vite-node fails to parse hashbang
4 participants