diff --git a/package.json b/package.json index af3bf06ff..cccb4836a 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "devDependencies": { "@babel/core": "^7.7.7", "@babel/preset-env": "^7.11.5", + "@intlify/vue-i18n-loader": "^3.0.0", "@types/estree": "^0.0.45", "@types/hash-sum": "^1.0.0", "@types/jest": "^26.0.13", @@ -81,6 +82,7 @@ "typescript": "^4.4.3", "url-loader": "^4.1.0", "vue": "^3.2.13", + "vue-i18n": "^9.1.7", "webpack": "^4.41.2", "webpack-cli": "^3.3.10", "webpack-dev-server": "^3.9.0", diff --git a/test/edgeCases.spec.ts b/test/edgeCases.spec.ts index 25e5b1fba..5aa3bde3f 100644 --- a/test/edgeCases.spec.ts +++ b/test/edgeCases.spec.ts @@ -203,3 +203,28 @@ test('data: URI as entry', async () => { }, }) }) + +// https://github.com/intlify/vue-i18n-next/issues/680 +test('should work with i18n loader in production mode', async () => { + const result = await mockBundleAndRun({ + mode: 'production', + entry: require.resolve('./fixtures/i18n-entry.js'), + module: { + rules: [ + { + test: /\.(json5?|ya?ml)$/, // target json, json5, yaml and yml files + type: 'javascript/auto', + loader: '@intlify/vue-i18n-loader', + }, + // for i18n custom block + { + resourceQuery: /blockType=i18n/, + type: 'javascript/auto', + loader: '@intlify/vue-i18n-loader', + }, + ], + }, + }) + + expect(result.componentModule.__i18n).toHaveLength(1) +}) diff --git a/test/fixtures/i18n-entry.js b/test/fixtures/i18n-entry.js new file mode 100644 index 000000000..6c1ffb43c --- /dev/null +++ b/test/fixtures/i18n-entry.js @@ -0,0 +1,23 @@ +import { createApp } from 'vue' +import { createI18n } from 'vue-i18n' + +import Component from './i18n.vue' +import * as exports from './i18n.vue' + +const i18n = createI18n({ + locale: 'de', + silentFallbackWarn: true, + silentTranslationWarn: true, +}) + +if (typeof window !== 'undefined') { + window.componentModule = Component + window.exports = exports + + const app = createApp(Component).use(i18n) + + const container = window.document.createElement('div') + window.instance = app.mount(container) +} + +export default Component diff --git a/test/fixtures/i18n.vue b/test/fixtures/i18n.vue new file mode 100644 index 000000000..1d9d6bc75 --- /dev/null +++ b/test/fixtures/i18n.vue @@ -0,0 +1,7 @@ + + + +test: Example Text + diff --git a/yarn.lock b/yarn.lock index b6fb75ee6..eff9f0852 100644 --- a/yarn.lock +++ b/yarn.lock @@ -873,6 +873,90 @@ exec-sh "^0.3.2" minimist "^1.2.0" +"@intlify/bundle-utils@^0.1.0": + version "0.1.0" + resolved "https://registry.yarnpkg.com/@intlify/bundle-utils/-/bundle-utils-0.1.0.tgz#09706be36efe46f4fe82eca223257cdd62cd6b58" + integrity sha512-v0aeQmjNWppSLpPcLh3E1JiQg8bQFY9uD4ZuZssGq2elXsqB3JDH0TZfhO8Y83x1Ejk0qxq5hv015mYS2qzfZQ== + dependencies: + "@intlify/core" "^9.1.6" + "@intlify/message-compiler" "^9.1.6" + "@intlify/shared" "^9.1.6" + jsonc-eslint-parser "^1.0.1" + source-map "^0.6.1" + yaml-eslint-parser "^0.3.2" + +"@intlify/core-base@9.1.7": + version "9.1.7" + resolved "https://registry.yarnpkg.com/@intlify/core-base/-/core-base-9.1.7.tgz#a454a492683690bc3d0abab82605ab5a23645bd0" + integrity sha512-q1W2j81xbHyfKrNcca/CeJyf0Bcx4u9UDu05l7AaiJbqOseTme2o2I3wp1hDDCtmC7k7HgX0sAygyHNJH9swuQ== + dependencies: + "@intlify/devtools-if" "9.1.7" + "@intlify/message-compiler" "9.1.7" + "@intlify/message-resolver" "9.1.7" + "@intlify/runtime" "9.1.7" + "@intlify/shared" "9.1.7" + "@intlify/vue-devtools" "9.1.7" + +"@intlify/core@^9.1.6": + version "9.1.7" + resolved "https://registry.yarnpkg.com/@intlify/core/-/core-9.1.7.tgz#69c00dc31111f1b61d79fbd9ad1838196e73c94a" + integrity sha512-iWlzl1CiG9iF0h+90ZkxLIgVkaznhmjcfR/bfXk/Usp/IqkeBV8z5QGxtuFdzS3iurOHfylUCopSaT87hPOGmw== + dependencies: + "@intlify/core-base" "9.1.7" + +"@intlify/devtools-if@9.1.7": + version "9.1.7" + resolved "https://registry.yarnpkg.com/@intlify/devtools-if/-/devtools-if-9.1.7.tgz#a5df0f33e06c3ead3e53b7f4d4b10a2d52309361" + integrity sha512-/DcN5FUySSkQhDqx5y1RvxfuCXO3Ot/dUEIOs472qbM7Hyb2qif+eXCnwHBzlI4+wEfQVT6L0PiM1a7Er/ro9g== + dependencies: + "@intlify/shared" "9.1.7" + +"@intlify/message-compiler@9.1.7", "@intlify/message-compiler@^9.1.6": + version "9.1.7" + resolved "https://registry.yarnpkg.com/@intlify/message-compiler/-/message-compiler-9.1.7.tgz#4663fcc2a190f3cc6970e12565c8d6f22beeb719" + integrity sha512-JZNkAhr3O7tnbdbRBcpYfqr/Ai26WTzX0K/lV8Y1KVdOIj/dGiamaffdWUdFiDXUnbJRNbPiOaKxy7Pwip3KxQ== + dependencies: + "@intlify/message-resolver" "9.1.7" + "@intlify/shared" "9.1.7" + source-map "0.6.1" + +"@intlify/message-resolver@9.1.7": + version "9.1.7" + resolved "https://registry.yarnpkg.com/@intlify/message-resolver/-/message-resolver-9.1.7.tgz#a95d13866c8de85784358039c8845668152e4162" + integrity sha512-WTK+OaXJYjyquLGhuCyDvU2WHkG+kXzXeHagmVFHn+s118Jf2143zzkLLUrapP5CtZ/csuyjmYg7b3xQRQAmvw== + +"@intlify/runtime@9.1.7": + version "9.1.7" + resolved "https://registry.yarnpkg.com/@intlify/runtime/-/runtime-9.1.7.tgz#67e0d6b2fd85a5b0b301a151c2f436f93154c3c6" + integrity sha512-QURPSlzhOVnRwS2XMGpCDsDkP42kfVBh94aAORxh/gVGzdgJip2vagrIFij/J69aEqdB476WJkMhVjP8VSHmiA== + dependencies: + "@intlify/message-compiler" "9.1.7" + "@intlify/message-resolver" "9.1.7" + "@intlify/shared" "9.1.7" + +"@intlify/shared@9.1.7", "@intlify/shared@^9.1.6": + version "9.1.7" + resolved "https://registry.yarnpkg.com/@intlify/shared/-/shared-9.1.7.tgz#e7d8bc90cb59dc17dd7b4c85a73db16fcb7891fc" + integrity sha512-zt0zlUdalumvT9AjQNxPXA36UgOndUyvBMplh8uRZU0fhWHAwhnJTcf0NaG9Qvr8I1n3HPSs96+kLb/YdwTavQ== + +"@intlify/vue-devtools@9.1.7": + version "9.1.7" + resolved "https://registry.yarnpkg.com/@intlify/vue-devtools/-/vue-devtools-9.1.7.tgz#b08d39bb5f21ba9b1954eab9466e9408129425a7" + integrity sha512-DI5Wc0aOiohtBUGUkKAcryCWbbuaO4/PK4Pa/LaNCsFNxbtgR5qkIDmhBv9xVPYGTUhySXxaDDAMvOpBjhPJjw== + dependencies: + "@intlify/message-resolver" "9.1.7" + "@intlify/runtime" "9.1.7" + "@intlify/shared" "9.1.7" + +"@intlify/vue-i18n-loader@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@intlify/vue-i18n-loader/-/vue-i18n-loader-3.0.0.tgz#76cc142bc05b8371085e2a48a4a3913698948ac6" + integrity sha512-Qb6JLkipgfdJnfrS/tJIRkNlK4igv3H1Fwy9g2VIU69KP30V15xfRoQo5hS+7UtZY6EeXew4wCal0LABWZw7vg== + dependencies: + "@intlify/bundle-utils" "^0.1.0" + "@intlify/shared" "^9.1.6" + loader-utils "^2.0.0" + "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -1492,6 +1576,11 @@ "@vue/compiler-dom" "3.2.13" "@vue/shared" "3.2.13" +"@vue/devtools-api@^6.0.0-beta.7": + version "6.0.0-beta.17" + resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.0.0-beta.17.tgz#d4b9eb02c670d39a4532f4bb3c8517abce3fcb82" + integrity sha512-hwGY4Xxc2nl34OyNH7l2VO8/ja3R78B8bcbaBQnZljSju5Z0Bm9HTt+/fQao+TUrs3gfNrrQrY3euWqiaG8chw== + "@vue/reactivity@3.2.13": version "3.2.13" resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.2.13.tgz#d269b09aaafef06a91bf3eb98defd41a2c3daf54" @@ -1873,6 +1962,11 @@ acorn-import-assertions@^1.7.6: resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.7.6.tgz#580e3ffcae6770eebeec76c3b9723201e9d01f78" integrity sha512-FlVvVFA1TX6l3lp8VjDnYYq7R1nyW6x3svAt4nDgrWQ9SBaSh9CnbwgSUTasgfNfOG5HlM1ehugCvM+hjo56LA== +acorn-jsx@^5.2.0: + version "5.3.2" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" + integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== + acorn-walk@^7.1.1: version "7.2.0" resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc" @@ -1898,6 +1992,11 @@ acorn@^7.1.1: resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.0.tgz#e1ad486e6c54501634c6c397c5c121daa383607c" integrity sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w== +acorn@^7.4.1: + version "7.4.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" + integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== + acorn@^8.4.1: version "8.4.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.4.1.tgz#56c36251fc7cabc7096adc18f05afe814321a28c" @@ -4016,6 +4115,27 @@ eslint-scope@^4.0.3: esrecurse "^4.1.0" estraverse "^4.1.1" +eslint-utils@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27" + integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg== + dependencies: + eslint-visitor-keys "^1.1.0" + +eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" + integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== + +espree@^6.0.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-6.2.1.tgz#77fc72e1fd744a2052c20f38a5b575832e82734a" + integrity sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw== + dependencies: + acorn "^7.1.1" + acorn-jsx "^5.2.0" + eslint-visitor-keys "^1.1.0" + esprima@^4.0.0, esprima@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" @@ -6040,6 +6160,17 @@ json5@^1.0.1: dependencies: minimist "^1.2.0" +jsonc-eslint-parser@^1.0.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/jsonc-eslint-parser/-/jsonc-eslint-parser-1.4.1.tgz#8cbe99f6f5199acbc5a823c4c0b6135411027fa6" + integrity sha512-hXBrvsR1rdjmB2kQmUjf1rEIa+TqHBGMge8pwi++C+Si1ad7EjZrJcpgwym+QGK/pqTx+K7keFAtLlVNdLRJOg== + dependencies: + acorn "^7.4.1" + eslint-utils "^2.1.0" + eslint-visitor-keys "^1.3.0" + espree "^6.0.0" + semver "^6.3.0" + jsonparse@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" @@ -8752,16 +8883,16 @@ source-map-url@^0.4.0: resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM= +source-map@0.6.1, source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + source-map@^0.5.0, source-map@^0.5.6, source-map@~0.5.1: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= -source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - source-map@^0.7.3, source-map@~0.7.2: version "0.7.3" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" @@ -9734,6 +9865,16 @@ void-elements@^2.0.1: resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" integrity sha1-wGavtYK7HLQSjWDqkjkulNXp2+w= +vue-i18n@^9.1.7: + version "9.1.7" + resolved "https://registry.yarnpkg.com/vue-i18n/-/vue-i18n-9.1.7.tgz#6f28dd2135197066508e2e65ab204a019750d773" + integrity sha512-ujuuDanoHqtEd4GejWrbG/fXE9nrP51ElsEGxp0WBHfv+/ki0/wyUqkO+4fLikki2obGtXdviTPH0VNpas5K6g== + dependencies: + "@intlify/core-base" "9.1.7" + "@intlify/shared" "9.1.7" + "@intlify/vue-devtools" "9.1.7" + "@vue/devtools-api" "^6.0.0-beta.7" + vue@^3.2.13: version "3.2.13" resolved "https://registry.yarnpkg.com/vue/-/vue-3.2.13.tgz#9d1a94fc62dc29ae21a3dd0d8ee24198e421671e" @@ -10145,6 +10286,15 @@ yallist@^4.0.0: resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== +yaml-eslint-parser@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/yaml-eslint-parser/-/yaml-eslint-parser-0.3.2.tgz#c7f5f3904f1c06ad55dc7131a731b018426b4898" + integrity sha512-32kYO6kJUuZzqte82t4M/gB6/+11WAuHiEnK7FreMo20xsCKPeFH5tDBU7iWxR7zeJpNnMXfJyXwne48D0hGrg== + dependencies: + eslint-visitor-keys "^1.3.0" + lodash "^4.17.20" + yaml "^1.10.0" + yaml@^1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"