Skip to content

Commit

Permalink
fix: avoid using commonjs for runtime (vite support)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 1, 2021
1 parent 03585e4 commit 3fc14ba
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/templates/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function stringifyValue(value) {

for (const [key, value] of Object.entries(options)) {
if (key === 'vueI18n' && typeof value === 'string') {
%>export const <%= key %> = require('<%= value %>').default
%>export const <%= key %> = () => import('<%= value %>').then(m => m.default)
<%
} else {
%>export const <%= key %> = <%= stringifyValue(value) %>
Expand Down
2 changes: 1 addition & 1 deletion src/templates/plugin.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
setLocaleCookie,
syncVuex
} from './utils-common'
import { loadLanguageAsync } from './utils'
import { klona } from '~i18n-klona'

Vue.use(VueI18n)
Expand Down Expand Up @@ -90,7 +91,6 @@ export default async (context) => {

// Lazy-loading enabled
if (lazy) {
const { loadLanguageAsync } = require('./utils')
const i18nFallbackLocale = app.i18n.fallbackLocale

// Load fallback locale(s).
Expand Down
2 changes: 1 addition & 1 deletion src/templates/utils-common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Cookie from 'cookie'
import JsCookie from 'js-cookie'
import isHTTPS from 'is-https'

/**
* Parses locales provided from browser through `accept-language` header.
Expand Down Expand Up @@ -104,7 +105,6 @@ export const getDomainFromLocale = (localeCode, req, { locales, localeDomainKey,
if (lang && lang[localeDomainKey]) {
let protocol
if (process.server) {
const isHTTPS = require('is-https')
protocol = (req && isHTTPS(req)) ? 'https' : 'http'
} else {
protocol = window.location.protocol.split(':')[0]
Expand Down

0 comments on commit 3fc14ba

Please sign in to comment.