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

fix(vite-node): Prevent crash when passing single module as options #1406

Merged
merged 2 commits into from Jun 4, 2022

Commits on May 31, 2022

  1. fix(vite-node): Prevent crash when passing single module as options

    Right now, when passing a single module with the new `--options` CLI flag, `cac` returns a string instead of an array. This causes a crash, trying to call `map` on it.
    
    ```
    ❯ ./packages/vite-node/vite-node.mjs --options.deps.inline="module" hello.js
    file:///Users/antoine/Code/vitest/packages/vite-node/dist/cli.js:697
          inline: (_b = (_a = serverOptions.deps) == null ? void 0 : _a.inline) == null ? void 0 : _b.map((dep) => {
                                                                                                      ^
    
    TypeError: _b.map is not a function
        at parseServerOptions (file:///Users/antoine/Code/vitest/packages/vite-node/dist/cli.js:697:99)
        at CAC.run (file:///Users/antoine/Code/vitest/packages/vite-node/dist/cli.js:660:49)
        at CAC.runMatchedCommand (file:///Users/antoine/Code/vitest/packages/vite-node/dist/cli.js:622:34)
        at CAC.parse (file:///Users/antoine/Code/vitest/packages/vite-node/dist/cli.js:549:12)
        at file:///Users/antoine/Code/vitest/packages/vite-node/dist/cli.js:652:5
        at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
        at async Promise.all (index 0)
        at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
    ```
    
    This PR updates the typings to reflect that, and makes sure that both `string` and `string[]` are properly handled.
    antoinerey committed May 31, 2022
    Copy the full SHA
    f1465d8 View commit details
    Browse the repository at this point in the history

Commits on Jun 1, 2022

  1. Copy the full SHA
    d218ee2 View commit details
    Browse the repository at this point in the history