originjs / vite-plugins

Other
172 stars 28 forks source link

Fix transformation issue of 'require' #26

Closed MartinKolbAtWork closed 2 years ago

MartinKolbAtWork commented 2 years ago

Fix proposal for issue https://github.com/originjs/vite-plugins/issues/25

ghost commented 1 year ago

This broke our code (webpack originally, but also using vite):

const messagesDE = {
  ...require('./i18n/de'),
  ...require('./i18n/errorcodes_de.json'),
  ...require('./i18n/requeststatus_de.json'),
}
const messagesEN = {
  ...require('./i18n/en'),
  ...require('./i18n/errorcodes_en.json'),
  ...require('./i18n/requeststatus_en.json'),
}
const messagesPL = require('./i18n/pl')
MartinKolbAtWork commented 1 year ago

This broke our code (webpack originally, but also using vite):

const messagesDE = {
  ...require('./i18n/de'),
  ...require('./i18n/errorcodes_de.json'),
  ...require('./i18n/requeststatus_de.json'),
}
const messagesEN = {
  ...require('./i18n/en'),
  ...require('./i18n/errorcodes_en.json'),
  ...require('./i18n/requeststatus_en.json'),
}
const messagesPL = require('./i18n/pl')

Thanks for finding this, @JannikGM I added a PR that will allow using the spread operator (...) preceeding the require statement: https://github.com/originjs/vite-plugins/pull/47