@open-xchange/vite-plugin-ox-manifests 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/index.d.ts +56 -0
  3. package/dist/index.js +175 -0
  4. package/dist/plugins/gettext.d.ts +2 -0
  5. package/dist/plugins/gettext.js +63 -0
  6. package/dist/plugins/manifests.d.ts +2 -0
  7. package/dist/plugins/manifests.js +132 -0
  8. package/dist/plugins/meta.d.ts +2 -0
  9. package/dist/plugins/meta.js +21 -0
  10. package/dist/plugins/plugin.d.ts +24 -0
  11. package/dist/plugins/plugin.js +6 -0
  12. package/dist/plugins/relative-paths.d.ts +2 -0
  13. package/dist/plugins/relative-paths.js +9 -0
  14. package/dist/plugins/serve.d.ts +2 -0
  15. package/dist/plugins/serve.js +66 -0
  16. package/dist/plugins/settings.d.ts +2 -0
  17. package/dist/plugins/settings.js +141 -0
  18. package/dist/util.d.ts +11 -0
  19. package/dist/util.js +77 -0
  20. package/package.json +24 -22
  21. package/.eslintrc.cjs +0 -10
  22. package/.gitlab-ci.yml +0 -26
  23. package/index.js +0 -172
  24. package/src/constants.js +0 -1
  25. package/src/plugins/gettext.js +0 -69
  26. package/src/plugins/manifests.js +0 -136
  27. package/src/plugins/meta.js +0 -13
  28. package/src/plugins/relative-paths.js +0 -7
  29. package/src/plugins/serve.js +0 -64
  30. package/src/plugins/settings.js +0 -147
  31. package/src/util.js +0 -61
  32. package/test/.eslintrc.cjs +0 -5
  33. package/test/deps/main.test.js +0 -32
  34. package/test/gettext-chunked/another_chunk.js +0 -4
  35. package/test/gettext-chunked/i18n/de_DE.po +0 -16
  36. package/test/gettext-chunked/i18n/en_US.po +0 -16
  37. package/test/gettext-chunked/main.test.js +0 -67
  38. package/test/gettext-chunked/manifest.json +0 -3
  39. package/test/gettext-chunked/register.js +0 -6
  40. package/test/gettext-multiple/i18n/de_DE.po +0 -22
  41. package/test/gettext-multiple/i18n/en_US.po +0 -22
  42. package/test/gettext-multiple/main.test.js +0 -71
  43. package/test/gettext-multiple/manifest.json +0 -3
  44. package/test/gettext-multiple/register.js +0 -4
  45. package/test/gettext-simple/i18n/de_DE.po +0 -18
  46. package/test/gettext-simple/i18n/en_US.po +0 -18
  47. package/test/gettext-simple/main.test.js +0 -61
  48. package/test/gettext-simple/manifest.json +0 -3
  49. package/test/gettext-simple/register.js +0 -3
  50. package/test/hmr/main.test.js +0 -121
  51. package/test/hmr/manifest.json +0 -3
  52. package/test/hmr/register.js +0 -1
  53. package/test/hmr/settings.js +0 -3
  54. package/test/html-relative-paths/index.html +0 -7
  55. package/test/html-relative-paths/index.js +0 -3
  56. package/test/html-relative-paths/main.test.js +0 -39
  57. package/test/html-relative-paths/other.html +0 -7
  58. package/test/html-relative-paths/style.css +0 -1
  59. package/test/manifest-dependencies/main.test.js +0 -26
  60. package/test/manifest-dependencies/manifest.json +0 -3
  61. package/test/manifest-dependencies/register.js +0 -3
  62. package/test/manifest-dependencies/style.less +0 -1
  63. package/test/manifest-dynamic-deps/main.test.js +0 -28
  64. package/test/manifest-dynamic-deps/manifest.json +0 -3
  65. package/test/manifest-dynamic-deps/register.js +0 -7
  66. package/test/manifest-dynamic-deps/some_dep.js +0 -5
  67. package/test/manifest-dynamic-deps/style.less +0 -1
  68. package/test/manifest-multiple/entry1.js +0 -1
  69. package/test/manifest-multiple/main.test.js +0 -83
  70. package/test/manifest-multiple/manifest.json +0 -7
  71. package/test/manifest-multiple/sub/entry2.js +0 -3
  72. package/test/manifest-multiple/sub/manifest.json +0 -4
  73. package/test/manifest-simple/main.test.js +0 -105
  74. package/test/manifest-simple/manifest.json +0 -3
  75. package/test/manifest-simple/register.js +0 -1
  76. package/test/meta/main.test.js +0 -25
  77. package/test/meta/manifest.json +0 -3
  78. package/test/meta/register.js +0 -1
  79. package/test/preload-helper-bundled/async.js +0 -1
  80. package/test/preload-helper-bundled/index.js +0 -1
  81. package/test/preload-helper-bundled/main.test.js +0 -32
  82. package/test/preload-helper-bundled/manifest.json +0 -4
  83. package/test/preload-helper-separate/bar.js +0 -1
  84. package/test/preload-helper-separate/foo.js +0 -3
  85. package/test/preload-helper-separate/index.js +0 -1
  86. package/test/preload-helper-separate/main.test.js +0 -34
  87. package/test/preload-helper-separate/manifest.json +0 -4
  88. package/test/settings-core/index.js +0 -4
  89. package/test/settings-core/main.test.js +0 -56
  90. package/test/settings-core/manifest.json +0 -4
  91. package/test/settings-core/no-settings.js +0 -3
  92. package/test/settings-core/settings.js +0 -3
  93. package/test/settings-external/index.js +0 -3
  94. package/test/settings-external/main.test.js +0 -61
  95. package/test/settings-external/manifest.json +0 -4
  96. package/test/settings-external/settings.js +0 -3
  97. package/test/settings-ts/index.js +0 -3
  98. package/test/settings-ts/main.test.js +0 -30
  99. package/test/settings-ts/manifest.json +0 -4
  100. package/test/settings-ts/settings.ts +0 -4
  101. package/test/settings-with-requirements/foo.js +0 -3
  102. package/test/settings-with-requirements/forth-settings.js +0 -3
  103. package/test/settings-with-requirements/index.js +0 -5
  104. package/test/settings-with-requirements/main.test.js +0 -95
  105. package/test/settings-with-requirements/manifest.json +0 -12
  106. package/test/settings-with-requirements/other-settings.js +0 -3
  107. package/test/settings-with-requirements/other.js +0 -4
  108. package/test/settings-with-requirements/settings.js +0 -3
  109. package/test/settings-with-requirements/third-settings.js +0 -3
  110. package/test/util/deep-merge.test.js +0 -59
  111. package/test/util.js +0 -16
@@ -1,136 +0,0 @@
1
- import path from 'path'
2
- import fs from 'fs'
3
- import fastGlob from 'fast-glob'
4
- import { applyInputToOptions, basepath, joinUrlPaths } from '../util.js'
5
-
6
- async function getManifestEntryFile (basePath, extensions) {
7
- if (path.extname(basePath)) {
8
- try {
9
- await fs.promises.stat(basePath)
10
- return path.parse(basePath)
11
- } catch (e) {
12
- throw new Error(`Cannot find file "${basePath}"`)
13
- }
14
- }
15
-
16
- for (const ext of extensions) {
17
- try {
18
- await fs.promises.stat(`${basePath}.${ext}`)
19
- return path.parse(`${basePath}.${ext}`)
20
- } catch (e) {}
21
- }
22
-
23
- throw new Error(`Cannot find file "${basePath}"`)
24
- }
25
-
26
- export default function ({ supportedEntryExtensions, entryPoints, manifestsAsEntryPoints } = {}) {
27
- const manifestModules = {}
28
- let resolvedConfig
29
- let viteManifestPlugin
30
-
31
- return {
32
- config (config) {
33
- if (config.build) {
34
- config.build.manifest = true
35
- } else {
36
- config.build = { manifest: true }
37
- }
38
- },
39
-
40
- configResolved (config) {
41
- resolvedConfig = config
42
-
43
- if (resolvedConfig.mode !== 'production') return
44
-
45
- // locate the vite:manifest plugin, copy and delete it
46
- const index = config.plugins.findIndex(({ name }) => name === 'vite:manifest')
47
- ;([viteManifestPlugin] = config.plugins.splice(index, 1))
48
-
49
- viteManifestPlugin.getManifests = (options, bundle) => {
50
- // manually invoke plugins functions
51
- return new Promise(resolve => {
52
- if (viteManifestPlugin.buildStart) viteManifestPlugin.buildStart()
53
- viteManifestPlugin.generateBundle.call({
54
- emitFile: ({ source }) => {
55
- resolve(JSON.parse(source))
56
- },
57
- getFileName: (id) => 'Not implemented'
58
- }, options, bundle)
59
- })
60
- }
61
- },
62
-
63
- async options (options) {
64
- const input = {}
65
-
66
- if (entryPoints) {
67
- const entryPointFiles = await fastGlob(entryPoints, { absolute: true })
68
- entryPointFiles.forEach(entry => {
69
- const baseLength = resolvedConfig.root.length + 1
70
- const extLength = path.extname(entry).length
71
- input[entry.substring(baseLength, entry.length - extLength)] = entry
72
- })
73
- }
74
-
75
- // 1. load all json files
76
- const root = resolvedConfig.root
77
- const entries = await fastGlob(`${root.replace(/\\/g, '/')}/**/manifest.json`)
78
- // 2. find every file that is referenced by that json file
79
- for (const entry of entries) {
80
- const rawData = await fs.promises.readFile(entry, 'utf-8')
81
- const json = JSON.parse(rawData)
82
- const manifests = [].concat(json)
83
- const manifestDir = path.dirname(entry).substr(root.length + 1)
84
-
85
- await Promise.all(manifests.map(async ({ path: srcManifestEntryPath = joinUrlPaths(manifestDir, 'register'), ...rest }) => {
86
- const { dir, base } = await getManifestEntryFile(joinUrlPaths(root, srcManifestEntryPath), supportedEntryExtensions)
87
- const manifestEntryPath = joinUrlPaths(dir, base)
88
-
89
- if (manifestsAsEntryPoints) {
90
- input[basepath(joinUrlPaths(path.dirname(srcManifestEntryPath), base))] = manifestEntryPath
91
- }
92
-
93
- // 3. put the file content except path into the manifest modules
94
- const modules = manifestModules[manifestEntryPath] || []
95
- manifestModules[manifestEntryPath] = modules.concat({ ...rest })
96
- }))
97
- }
98
-
99
- if (resolvedConfig.mode === 'production') {
100
- applyInputToOptions(input, options)
101
- }
102
- return options
103
- },
104
-
105
- // specific call to collect all manifests
106
- getManifests () {
107
- return Object.entries(manifestModules).map(
108
- ([path, manifests]) => manifests.map(m => ({ ...m, path: basepath(path.substr(resolvedConfig.root.length + 1)) }))
109
- ).flat(1)
110
- },
111
-
112
- transform (code, id) {
113
- if (resolvedConfig.mode !== 'production') return
114
-
115
- if (manifestModules[id]) {
116
- return { meta: { manifests: manifestModules[id] } }
117
- }
118
- },
119
-
120
- async generateBundle (options, bundle) {
121
- const viteManifests = await viteManifestPlugin.getManifests(options, bundle)
122
-
123
- for (const entry in viteManifests) {
124
- const chunk = bundle[viteManifests[entry].file]
125
- if (!chunk.facadeModuleId) continue
126
- viteManifests[entry].meta = this.getModuleInfo(chunk.facadeModuleId).meta
127
- }
128
-
129
- this.emitFile({
130
- fileName: 'manifest.json',
131
- type: 'asset',
132
- source: JSON.stringify(viteManifests)
133
- })
134
- }
135
- }
136
- }
@@ -1,13 +0,0 @@
1
- export default function ({ meta } = {}) {
2
- return {
3
- generateBundle () {
4
- if (!meta || Object.keys(meta).length === 0) return
5
-
6
- this.emitFile({
7
- fileName: 'meta.json',
8
- type: 'asset',
9
- source: JSON.stringify(meta)
10
- })
11
- }
12
- }
13
- }
@@ -1,7 +0,0 @@
1
- import { PROJECT_NAME as name } from '../constants.js'
2
- import MagicString from 'magic-string'
3
-
4
- export default function ({ transformAbsolutePaths } = {}) {
5
- if (transformAbsolutePaths !== undefined) console.warn("transformAbsolutePaths is no longer used. Use `base: './'` with vite 3")
6
- return {}
7
- }
@@ -1,64 +0,0 @@
1
- import path, { posix } from 'path'
2
- import parseurl from 'parseurl'
3
- import chokidar from 'chokidar'
4
-
5
- const sendJSON = (res, data) => {
6
- res.statusCode = 200
7
- res.setHeader('Content-Type', 'application/json')
8
- res.write(JSON.stringify(data))
9
- return res.end()
10
- }
11
-
12
- export default function ({ watch } = {}) {
13
- let resolvedConfig
14
- let manifestRegex
15
- let depsRegex
16
-
17
- return {
18
- configResolved (config) {
19
- resolvedConfig = config
20
- manifestRegex = new RegExp(`^${config.base}(api/manifest.json|manifests)$`)
21
- depsRegex = new RegExp(`^${config.base}(api/deps.json|dependencies)$`)
22
- },
23
-
24
- async configureServer ({ ws, middlewares, moduleGraph }) {
25
- const addTimestamp = (manifests) => {
26
- manifests.forEach(manifest => {
27
- // TODO what about other file types?
28
- const id = `${resolvedConfig.root}/${manifest.path}.js`
29
- const moduleNode = moduleGraph.idToModuleMap.get(id)
30
- if (!moduleNode) return
31
- const hmrTS = moduleNode.lastHMRTimestamp
32
- if (!hmrTS) return
33
- manifest.raw = posix.join(resolvedConfig.base, `/${manifest.path}.js?t=${hmrTS}`)
34
- })
35
- }
36
-
37
- middlewares.use(async (req, res, next) => {
38
- const { path } = parseurl(req)
39
- if (req.method !== 'GET') return next()
40
-
41
- if (manifestRegex.test(path)) {
42
- const manifests = await this.getManifests()
43
- await addTimestamp(manifests)
44
- return sendJSON(res, manifests)
45
- }
46
-
47
- if (depsRegex.test(path)) {
48
- return sendJSON(res, {})
49
- }
50
-
51
- next()
52
- })
53
-
54
- if (watch) {
55
- const watcher = chokidar.watch(path.join(resolvedConfig.root, '**/manifest.json'))
56
- .on('ready', async () => {
57
- watcher.on('all', async (path) => {
58
- ws.send({ type: 'full-reload', path })
59
- })
60
- })
61
- }
62
- }
63
- }
64
- }
@@ -1,147 +0,0 @@
1
- import fastGlob from 'fast-glob'
2
- import fs from 'fs'
3
- import path, { posix } from 'path'
4
- import { applyInputToOptions, basepath } from '../util.js'
5
-
6
- function getRequirements (entry) {
7
- const moduleInfo = this.getModuleInfo(entry)
8
- const open = [].concat(moduleInfo.importers).concat(moduleInfo.dynamicImporters)
9
- const closed = {}
10
- const entryPoints = []
11
- open.forEach(o => (closed[o] = true))
12
-
13
- while (open.length > 0) {
14
- const first = open.shift()
15
- if (first.indexOf('node_modules') >= 0) continue
16
-
17
- const moduleInfo = this.getModuleInfo(first)
18
- if (moduleInfo.isEntry) {
19
- if (moduleInfo.meta?.manifests) {
20
- entryPoints.push.apply(entryPoints, moduleInfo.meta.manifests.map(manifest => ({ requires: 'true', ...manifest })))
21
- continue
22
- }
23
- }
24
-
25
- const nextOpen = [].concat(moduleInfo.importers).concat(moduleInfo.dynamicImporters).filter(o => !closed[o])
26
- nextOpen.forEach(o => (closed[o] = true))
27
- open.push(...nextOpen)
28
- }
29
-
30
- return [...new Set(entryPoints.map(e => e.requires).filter(Boolean))]
31
- }
32
-
33
- function mergeRequirements (requirements) {
34
- if (requirements.length === 0) return
35
- if (requirements.includes('true')) return
36
- return requirements.map(c => {
37
- // check if is just a simple string
38
- if (/^[-\w]*$/.test(c)) return c
39
- return `(${c})`
40
- }).join('||')
41
- }
42
-
43
- export const getExternalsPrefix = (() => {
44
- let cache
45
- return function (resolvedConfig) {
46
- if (cache === undefined) {
47
- const externalPlugin = resolvedConfig.plugins.find(p => p.name === '@open-xchange/vite-plugin-ox-externals')
48
- cache = externalPlugin?.meta?.prefix || ''
49
- }
50
- return cache
51
- }
52
- })()
53
-
54
- const containsExportRegex = /export const settings = new Settings\(/
55
- export async function isSettingsFile (entry, resolvedConfig) {
56
- const externalPrefix = getExternalsPrefix(resolvedConfig)
57
- const containsSettingsRegex = new RegExp(`import.+[,\\s]Settings.+from ['"][@${externalPrefix}]\\/io.ox\\/core\\/settings(\\.js)?['"]`)
58
-
59
- const content = await fs.promises.readFile(entry, { encoding: 'utf-8' })
60
- // special case
61
- if (entry === `${resolvedConfig.root}/io.ox/core/settings.js`) return true
62
- return containsSettingsRegex.test(content) && containsExportRegex.test(content)
63
- }
64
-
65
- export default function ({ autoloadSettings } = {}) {
66
- const settingsModules = {}
67
- let resolvedConfig, moduleGraph
68
-
69
- return {
70
- configResolved (config) {
71
- resolvedConfig = config
72
- },
73
-
74
- async options (options) {
75
- if (!autoloadSettings) return
76
-
77
- const input = {}
78
- const root = resolvedConfig.root
79
- const entries = await fastGlob(`${root.replace(/\\/g, '/')}/**/*.{js,ts,mjs}`, { absolute: true })
80
- await Promise.all(entries.map(async (entry) => {
81
- if (!await isSettingsFile(entry, resolvedConfig)) return
82
-
83
- settingsModules[entry] = { namespace: 'settings', generator: 'settings' }
84
-
85
- const baseLength = root.length + 1
86
- const extLength = path.extname(entry).length
87
- const entryPath = entry.substring(baseLength, entry.length - extLength)
88
- input[entryPath] = entry
89
- }))
90
-
91
- if (resolvedConfig.mode === 'production') {
92
- applyInputToOptions(input, options)
93
- }
94
-
95
- return options
96
- },
97
-
98
- configureServer ({ moduleGraph: mg }) {
99
- moduleGraph = mg
100
- },
101
-
102
- // specific call to collect all manifests
103
- getManifests () {
104
- return Object.entries(settingsModules).map(
105
- ([path, m]) => {
106
- const newPath = basepath(path.substr(resolvedConfig.root.length + 1))
107
- const manifest = { ...m, path: newPath }
108
- const moduleNode = moduleGraph?.idToModuleMap.get(path)
109
- if (moduleNode?.lastHMRTimestamp) {
110
- manifest.raw = posix.join(resolvedConfig.base, `/${manifest.path}.js?t=${moduleNode.lastHMRTimestamp}`)
111
- }
112
- return manifest
113
- }
114
- )
115
- },
116
-
117
- transform (code, id) {
118
- if (resolvedConfig.mode !== 'production') return
119
-
120
- if (settingsModules[id]) {
121
- return { meta: { manifests: [settingsModules[id]] } }
122
- }
123
- },
124
-
125
- async generateBundle (options, bundle) {
126
- if (!autoloadSettings) return
127
-
128
- for (const file in bundle) {
129
- const chunk = bundle[file]
130
- if (!chunk.facadeModuleId) continue
131
- const meta = this.getModuleInfo(chunk.facadeModuleId)?.meta
132
- if (!meta?.manifests) continue
133
-
134
- meta.manifests.forEach(manifest => {
135
- if (manifest.generator !== 'settings') return
136
- delete manifest.generator
137
-
138
- const requirements = getRequirements.call(this, chunk.facadeModuleId, resolvedConfig)
139
- if (!requirements.length) return
140
-
141
- const requires = mergeRequirements(requirements)
142
- if (requires) manifest.requires = requires
143
- })
144
- }
145
- }
146
- }
147
- }
package/src/util.js DELETED
@@ -1,61 +0,0 @@
1
- import path from 'path'
2
-
3
- export function applyInputToOptions (input, options) {
4
- // apply changes to input
5
- if (Object.keys(input).length > 0) {
6
- if (options.input) {
7
- if (typeof options.input === 'string') {
8
- input.index = options.input
9
- options.input = input
10
- } else if (options.input instanceof Array) {
11
- options.input = [...options.input, ...Object.values(input)]
12
- } else {
13
- Object.assign(input, options.input)
14
- options.input = input
15
- }
16
- }
17
- }
18
- }
19
-
20
- export function joinUrlPaths (...paths) {
21
- return path.join.apply(path, paths).replace(/\\+/g, '/')
22
- }
23
-
24
- export function basepath (src) {
25
- const { dir, name } = path.parse(src)
26
- return joinUrlPaths(dir, name)
27
- }
28
-
29
- export function deepMergeObject (a, b) {
30
- const keys = [...new Set(Object.keys(a).concat(Object.keys(b)))]
31
- const result = {}
32
-
33
- for (const key of keys) {
34
- if (a[key] === undefined) result[key] = b[key]
35
- else if (b[key] === undefined) result[key] = a[key]
36
- else if ((a[key] instanceof Array) !== (b[key] instanceof Array)) throw new Error('Cannot merge different types')
37
- else if (typeof a[key] !== typeof b[key]) throw new Error('Cannot merge different types')
38
- else if (a[key] instanceof Array) result[key] = [...a[key], ...b[key]]
39
- else if (typeof a[key] === 'object') result[key] = deepMergeObject(a[key], b[key])
40
- else result[key] = b[key]
41
- }
42
-
43
- return result
44
- }
45
-
46
- export function waitForReload (server) {
47
- return new Promise(resolve => {
48
- const prev = server.ws.send
49
- server.ws.send = function ({ type } = {}) {
50
- try {
51
- return prev.apply(this, arguments)
52
- } finally {
53
- if (type === 'full-reload') resolve()
54
- }
55
- }
56
- })
57
- }
58
-
59
- export function wait (millis) {
60
- return new Promise(resolve => setTimeout(resolve, millis))
61
- }
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- plugins: [
3
- 'jest'
4
- ]
5
- }
@@ -1,32 +0,0 @@
1
- import { describe, it, expect, afterEach } from '@jest/globals'
2
- import { createServer } from 'vite'
3
- import path from 'path'
4
- import vitePluginOxManifests from '../../index'
5
- import { getPort } from '../util'
6
-
7
- const PORT = getPort()
8
- const __dirname = path.dirname(new URL(import.meta.url).pathname)
9
-
10
- describe('deps', function () {
11
- let server
12
-
13
- afterEach(async function () {
14
- if (server) {
15
- await server.close()
16
- server = null
17
- }
18
- })
19
-
20
- it('deliver empty deps in dev mode', async function () {
21
- server = await createServer({
22
- root: __dirname,
23
- logLevel: 'silent',
24
- plugins: [vitePluginOxManifests({})]
25
- })
26
- await server.listen(PORT)
27
-
28
- const res = await fetch(`http://localhost:${PORT}/api/deps.json`)
29
- const deps = await res.json()
30
- expect(deps).toEqual({})
31
- })
32
- })
@@ -1,4 +0,0 @@
1
- import gt from 'gettext'
2
-
3
- export const five = 5
4
- export default gt('five')
@@ -1,16 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: \n"
4
- "PO-Revision-Date: 2014-01-15 14:13+0100\n"
5
- "Last-Translator: Julian Bäume <julian.baeume@open-xchange.com>\n"
6
- "Language-Team: German <julian.baeume@open-xchange.com>\n"
7
- "Language: de_DE\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "X-Generator: Lokalize 1.5\n"
13
-
14
- #: module:i18n
15
- msgid "Hello world!"
16
- msgstr "Hallo Welt!"
@@ -1,16 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: \n"
4
- "PO-Revision-Date: 2014-01-15 14:13+0100\n"
5
- "Last-Translator: Julian Bäume <julian.baeume@open-xchange.com>\n"
6
- "Language-Team: German <julian.baeume@open-xchange.com>\n"
7
- "Language: en_US\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "X-Generator: Lokalize 1.5\n"
13
-
14
- #: module:i18n
15
- msgid "Hello world!"
16
- msgstr ""
@@ -1,67 +0,0 @@
1
- import { describe, it, expect, afterEach } from '@jest/globals'
2
- import { build, createServer } from 'vite'
3
- import path from 'path'
4
- import vitePluginOxManifests from '../../index'
5
- import rollupPluginPo2Json from '@open-xchange/rollup-plugin-po2json'
6
- import { getFileFromBundle, getPort } from '../util'
7
-
8
- const PORT = getPort()
9
- const __dirname = path.dirname(new URL(import.meta.url).pathname)
10
-
11
- describe('Dictionary in modules with dynamic imports', function () {
12
- let server
13
-
14
- afterEach(async function () {
15
- if (server) {
16
- await server.close()
17
- server = null
18
- }
19
- })
20
-
21
- it('works', async function () {
22
- const bundle = await build({
23
- root: __dirname,
24
- logLevel: 'silent',
25
- build: {
26
- write: false,
27
- rollupOptions: {
28
- input: { }
29
- }
30
- },
31
- plugins: [rollupPluginPo2Json({
32
- poFiles: __dirname + '/i18n/*.po'
33
- }), vitePluginOxManifests({
34
-
35
- })]
36
- })
37
-
38
- const manifestFile = getFileFromBundle('manifest', bundle)
39
- const manifests = JSON.parse(manifestFile.source)
40
- expect(Object.keys(manifests)).toHaveLength(7)
41
- expect(manifests['register.js'].meta.manifests[0].namespace).toEqual('test')
42
- expect(manifests['../../i18n.js'].meta.gettext.dictionary).toEqual(true)
43
- expect(manifests['../../i18n.js'].meta.manifests[0].namespace).toEqual('i18n')
44
- })
45
-
46
- it('works in dev mode', async function () {
47
- server = await createServer({
48
- root: __dirname,
49
- logLevel: 'silent',
50
- plugins: [rollupPluginPo2Json({
51
- poFiles: __dirname + '/i18n/*.po'
52
- }), vitePluginOxManifests({
53
-
54
- })]
55
- })
56
- await server.listen(PORT)
57
-
58
- const res = await fetch(`http://localhost:${PORT}/api/manifest.json`)
59
- const manifests = await res.json()
60
-
61
- expect(manifests).toHaveLength(2)
62
- expect(manifests[0].namespace).toEqual('i18n')
63
- expect(manifests[0].path).toEqual('i18n')
64
- expect(manifests[1].namespace).toEqual('test')
65
- expect(manifests[1].path).toContain('register')
66
- })
67
- })
@@ -1,3 +0,0 @@
1
- {
2
- "namespace": "test"
3
- }
@@ -1,6 +0,0 @@
1
- import gt from 'gettext'
2
-
3
- export async function doSomethingDynamic () {
4
- const { five } = await import('./another_chunk.js')
5
- console.log(gt('Hello world!'), five)
6
- }
@@ -1,22 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: \n"
4
- "PO-Revision-Date: 2014-01-15 14:13+0100\n"
5
- "Last-Translator: Julian Bäume <julian.baeume@open-xchange.com>\n"
6
- "Language-Team: German <julian.baeume@open-xchange.com>\n"
7
- "Language: de_DE\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "X-Generator: Lokalize 1.5\n"
13
-
14
- #. empty is meant as a state (folder is empty)
15
- #: module:i18n
16
- msgctxt "describe state"
17
- msgid "Empty folder"
18
- msgstr "Leerer Ordner"
19
-
20
- #: module:foobar
21
- msgid "String with \" in it"
22
- msgstr "Zeichenkette mit \""
@@ -1,22 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: \n"
4
- "PO-Revision-Date: 2014-01-15 14:13+0100\n"
5
- "Last-Translator: Julian Bäume <julian.baeume@open-xchange.com>\n"
6
- "Language-Team: German <julian.baeume@open-xchange.com>\n"
7
- "Language: en_US\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "X-Generator: Lokalize 1.5\n"
13
-
14
- #. empty is meant as a state (folder is empty)
15
- #: module:i18n
16
- msgctxt "describe state"
17
- msgid "Empty folder"
18
- msgstr ""
19
-
20
- #: module:foobar
21
- msgid "String with \" in it"
22
- msgstr ""