diff --git a/packages/config/package.json b/packages/config/package.json index 6768f2caab..e715f0a4a9 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -10,7 +10,7 @@ "index.d.ts" ], "dependencies": { - "@nuxt/ufo": "^0.0.3", + "@nuxt/ufo": "^0.1.0", "@nuxt/utils": "2.14.10", "consola": "^2.15.0", "create-require": "^1.1.1", diff --git a/packages/config/src/options.js b/packages/config/src/options.js index f1701fad26..29424d084d 100644 --- a/packages/config/src/options.js +++ b/packages/config/src/options.js @@ -7,7 +7,7 @@ import uniq from 'lodash/uniq' import consola from 'consola' import destr from 'destr' import { TARGETS, MODES, guardDir, isNonEmptyString, isPureObject, isUrl, getMainModule, urlJoin, getPKG } from '@nuxt/utils' -import { normalizeURL } from '@nuxt/ufo' +import { normalizeURL, withTrailingSlash } from '@nuxt/ufo' import { defaultNuxtConfigFile, getDefaultNuxtConfig } from './config' export function getNuxtConfig (_options) { @@ -124,10 +124,7 @@ export function getNuxtConfig (_options) { defaultsDeep(options, modePreset || options.modes[MODES.universal]) // Sanitize router.base - if (!/\/$/.test(options.router.base)) { - options.router.base += '/' - } - options.router.base = normalizeURL(options.router.base) + options.router.base = withTrailingSlash(normalizeURL(options.router.base)) // Legacy support for export if (options.export) { diff --git a/packages/utils/package.json b/packages/utils/package.json index 1be6b05132..6cfd0c0c85 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -8,7 +8,7 @@ "dist" ], "dependencies": { - "@nuxt/ufo": "^0.0.3", + "@nuxt/ufo": "^0.1.0", "consola": "^2.15.0", "fs-extra": "^8.1.0", "hash-sum": "^2.0.0", diff --git a/packages/utils/src/route.js b/packages/utils/src/route.js index d09eea26db..abd5868222 100644 --- a/packages/utils/src/route.js +++ b/packages/utils/src/route.js @@ -201,7 +201,7 @@ export const createRoutes = function createRoutes ({ } else if (key === 'index' && i + 1 === keys.length) { route.path += i > 0 ? '' : '/' } else { - route.path += normalizeURL(getRoutePathExtension(key)) + route.path += '/' + normalizeURL(getRoutePathExtension(key)) if (key.startsWith('_') && key.length > 1) { route.path += '?' } diff --git a/packages/vue-app/package.json b/packages/vue-app/package.json index 76682bcf16..786dd8ce66 100644 --- a/packages/vue-app/package.json +++ b/packages/vue-app/package.json @@ -13,7 +13,7 @@ "index.d.ts" ], "dependencies": { - "@nuxt/ufo": "^0.0.3", + "@nuxt/ufo": "^0.1.0", "node-fetch": "^2.6.1", "unfetch": "^4.2.0", "vue": "^2.6.12", diff --git a/packages/webpack/package.json b/packages/webpack/package.json index ad219002e6..1ebb18dd54 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -43,6 +43,7 @@ "thread-loader": "^2.1.3", "time-fix-plugin": "^2.0.7", "url-loader": "^2.3.0", + "url-polyfill": "^1.1.12", "vue-loader": "^15.9.5", "webpack": "^4.44.2", "webpack-bundle-analyzer": "^3.9.0", diff --git a/packages/webpack/src/config/client.js b/packages/webpack/src/config/client.js index 3a3d7ee72d..7916fdd60b 100644 --- a/packages/webpack/src/config/client.js +++ b/packages/webpack/src/config/client.js @@ -63,7 +63,7 @@ export default class WebpackClientConfig extends WebpackBaseConfig { cacheGroups.commons === undefined ) { cacheGroups.commons = { - test: /node_modules[\\/](vue|vue-loader|vue-router|vuex|vue-meta|core-js|@babel\/runtime|axios|webpack|setimmediate|timers-browserify|process|regenerator-runtime|cookie|js-cookie|is-buffer|dotprop|nuxt\.js)[\\/]/, + test: /node_modules[\\/](vue|vue-loader|vue-router|vuex|vue-meta|core-js|@babel\/runtime|axios|webpack|setimmediate|timers-browserify|process|regenerator-runtime|cookie|js-cookie|is-buffer|dotprop|url-polyfill|nuxt\.js)[\\/]/, chunks: 'all', name: true, priority: 10 @@ -205,6 +205,11 @@ export default class WebpackClientConfig extends WebpackBaseConfig { ) } + // Add URL polyfill for IE11 support with ufo + if (!this.isModern && !this.isServer) { + config.entry.app.unshift(require.resolve('url-polyfill/url-polyfill.min.js')) + } + // Add friendly error plugin if (this.dev && !quiet && friendlyErrors) { config.plugins.push( diff --git a/test/dev/async-config.size-limit.test.js b/test/dev/async-config.size-limit.test.js index 52977e1c8b..cf7adb36be 100644 --- a/test/dev/async-config.size-limit.test.js +++ b/test/dev/async-config.size-limit.test.js @@ -20,20 +20,20 @@ describe('nuxt basic resources size limit', () => { it('should stay within the size limit range in legacy mode', async () => { const legacyResourcesSize = await getResourcesSize(distDir, 'client', { gzip: true, brotli: true }) - const LEGACY_JS_RESOURCES_KB_SIZE = 201 + const LEGACY_JS_RESOURCES_KB_SIZE = 217 expect(legacyResourcesSize.uncompressed).toBeWithinSize(LEGACY_JS_RESOURCES_KB_SIZE) const LEGACY_JS_RESOURCES_GZIP_KB_SIZE = 70 expect(legacyResourcesSize.gzip).toBeWithinSize(LEGACY_JS_RESOURCES_GZIP_KB_SIZE) - const LEGACY_JS_RESOURCES_BROTLI_KB_SIZE = 60 + const LEGACY_JS_RESOURCES_BROTLI_KB_SIZE = 64 expect(legacyResourcesSize.brotli).toBeWithinSize(LEGACY_JS_RESOURCES_BROTLI_KB_SIZE) }) it('should stay within the size limit range in modern mode', async () => { const modernResourcesSize = await getResourcesSize(distDir, 'modern', { gzip: true, brotli: true }) - const MODERN_JS_RESOURCES_KB_SIZE = 172 + const MODERN_JS_RESOURCES_KB_SIZE = 180 expect(modernResourcesSize.uncompressed).toBeWithinSize(MODERN_JS_RESOURCES_KB_SIZE) const MODERN_JS_RESOURCES_GZIP_KB_SIZE = 60 diff --git a/yarn.lock b/yarn.lock index 741b2a6246..4d3efd4554 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1955,10 +1955,10 @@ rc9 "^1.2.0" std-env "^2.2.1" -"@nuxt/ufo@^0.0.3": - version "0.0.3" - resolved "https://registry.npmjs.org/@nuxt/ufo/-/ufo-0.0.3.tgz#7673a54b81c020e7aea3a9e01e09a58c494a1eca" - integrity sha512-LQkuVafVNB9+ggRF7443AX1V1rEWRs32Frk7F2qnRLf8j/SzRzxEZ99jiZqxVho72zU7NcWQ6Jy62m4fkZC6Wg== +"@nuxt/ufo@^0.1.0": + version "0.1.0" + resolved "https://registry.npmjs.org/@nuxt/ufo/-/ufo-0.1.0.tgz#4943741c4300b73e4f1de09cad684ed4e9235502" + integrity sha512-7az26cl4TaNejTFlgwcGRIGPFH6tD8dLh1t+Q+BWIM8UQqqV9o2DH9yKcVlboP+LdocLBUC+OTOiZc0RSZh0bA== "@nuxtjs/eslint-config@^5.0.0": version "5.0.0" @@ -13205,6 +13205,11 @@ url-loader@^2.3.0: mime "^2.4.4" schema-utils "^2.5.0" +url-polyfill@^1.1.12: + version "1.1.12" + resolved "https://registry.npmjs.org/url-polyfill/-/url-polyfill-1.1.12.tgz#6cdaa17f6b022841b3aec0bf8dbd87ac0cd33331" + integrity sha512-mYFmBHCapZjtcNHW0MDq9967t+z4Dmg5CJ0KqysK3+ZbyoNOWQHksGCTWwDhxGXllkWlOc10Xfko6v4a3ucM6A== + url@^0.11.0: version "0.11.0" resolved "https://registry.npmjs.org/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1"