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!: support multiline values in env files #10826

Merged
merged 7 commits into from Nov 30, 2022
Merged

Conversation

Dunqing
Copy link
Contributor

@Dunqing Dunqing commented Nov 8, 2022

Description

close: #10149
related PR: #10370

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@sapphi-red sapphi-red added breaking change p3-significant High priority enhancement (priority) labels Nov 8, 2022
@sapphi-red
Copy link
Member

Thanks for splitting the PR!

It would be nice if we could have a better error message for #6858.
TypeError: Cannot read properties of undefined (reading 'split') is quite difficult to understand.
#6858 (comment)

@Dunqing
Copy link
Contributor Author

Dunqing commented Nov 9, 2022

@sapphi-red I'm trying to fix TypeError: Cannot read properties of undefined (reading 'split') if you have a better way to fix it, please come to motdotla/dotenv-expand#85 and give me some suggestions. Thanks!

@bluwy bluwy added this to the 4.0 milestone Nov 19, 2022
packages/vite/src/node/env.ts Outdated Show resolved Hide resolved
@bluwy bluwy changed the title chore(vite): support multiline values in env files feat!: support multiline values in env files Nov 22, 2022
bluwy
bluwy previously approved these changes Nov 28, 2022
@bluwy
Copy link
Member

bluwy commented Nov 28, 2022

It would be nice if we could have a better error message for #6858.
TypeError: Cannot read properties of undefined (reading 'split') is quite difficult to understand.
#6858 (comment)

Unless we have a hardcoded error check for the split undefined bug, I think it would be nicer if it's fixed upstream 🤔

@Dunqing
Copy link
Contributor Author

Dunqing commented Nov 28, 2022

Unless we have a hardcoded error check for the split undefined bug, I think it would be nicer if it's fixed upstream 🤔

Can we re-implement dotenv-expand in vite?

@bluwy
Copy link
Member

bluwy commented Nov 29, 2022

I think it's better to keep it upstream for now so it gets bug fixes and we can refer to its docs.

@sapphi-red
Copy link
Member

sapphi-red commented Nov 29, 2022

Unless we have a hardcoded error check for the split undefined bug, I think it would be nicer if it's fixed upstream 🤔

Yeah, I think it would be better to be fixed in upstream. But until that get fixed, I think we should improve the error message on our side. Something like:

try {
  expand()
} catch (e) {
  if (e.message.includes('split') {
    throw new Error('dotenv-expand failed to expand env vars. Maybe you need to escape `$`?')
  }
  throw e
}

Without that, I suppose we'll receive many bug reports.

@bluwy
Copy link
Member

bluwy commented Nov 29, 2022

I'd be fine with a custom error check for now too 👍

@patak-dev
Copy link
Member

Let's merge and improve the error message in a follow-up PR. Let us know if you want to take that @Dunqing. I want to include this already in the next patch.

@patak-dev patak-dev merged commit 606e60d into vitejs:main Nov 30, 2022
@sapphi-red
Copy link
Member

@Dunqing Just to confirm, do you plan to take the error one? I'll take that if you don't.

@Dunqing
Copy link
Contributor Author

Dunqing commented Dec 1, 2022

@Dunqing Just to confirm, do you plan to take the error one? I'll take that if you don't.

Sorry, I'll do that soon.

@sapphi-red
Copy link
Member

@Dunqing OK. No rush 👍🏼

futurGH pushed a commit to futurGH/vite that referenced this pull request Feb 26, 2023
Co-authored-by: bluwy <bjornlu.dev@gmail.com>
close vitejs#10149
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change p3-significant High priority enhancement (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Multiline values in env files
4 participants