@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.
- package/CHANGELOG.md +39 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +175 -0
- package/dist/plugins/gettext.d.ts +2 -0
- package/dist/plugins/gettext.js +63 -0
- package/dist/plugins/manifests.d.ts +2 -0
- package/dist/plugins/manifests.js +132 -0
- package/dist/plugins/meta.d.ts +2 -0
- package/dist/plugins/meta.js +21 -0
- package/dist/plugins/plugin.d.ts +24 -0
- package/dist/plugins/plugin.js +6 -0
- package/dist/plugins/relative-paths.d.ts +2 -0
- package/dist/plugins/relative-paths.js +9 -0
- package/dist/plugins/serve.d.ts +2 -0
- package/dist/plugins/serve.js +66 -0
- package/dist/plugins/settings.d.ts +2 -0
- package/dist/plugins/settings.js +141 -0
- package/dist/util.d.ts +11 -0
- package/dist/util.js +77 -0
- package/package.json +24 -22
- package/.eslintrc.cjs +0 -10
- package/.gitlab-ci.yml +0 -26
- package/index.js +0 -172
- package/src/constants.js +0 -1
- package/src/plugins/gettext.js +0 -69
- package/src/plugins/manifests.js +0 -136
- package/src/plugins/meta.js +0 -13
- package/src/plugins/relative-paths.js +0 -7
- package/src/plugins/serve.js +0 -64
- package/src/plugins/settings.js +0 -147
- package/src/util.js +0 -61
- package/test/.eslintrc.cjs +0 -5
- package/test/deps/main.test.js +0 -32
- package/test/gettext-chunked/another_chunk.js +0 -4
- package/test/gettext-chunked/i18n/de_DE.po +0 -16
- package/test/gettext-chunked/i18n/en_US.po +0 -16
- package/test/gettext-chunked/main.test.js +0 -67
- package/test/gettext-chunked/manifest.json +0 -3
- package/test/gettext-chunked/register.js +0 -6
- package/test/gettext-multiple/i18n/de_DE.po +0 -22
- package/test/gettext-multiple/i18n/en_US.po +0 -22
- package/test/gettext-multiple/main.test.js +0 -71
- package/test/gettext-multiple/manifest.json +0 -3
- package/test/gettext-multiple/register.js +0 -4
- package/test/gettext-simple/i18n/de_DE.po +0 -18
- package/test/gettext-simple/i18n/en_US.po +0 -18
- package/test/gettext-simple/main.test.js +0 -61
- package/test/gettext-simple/manifest.json +0 -3
- package/test/gettext-simple/register.js +0 -3
- package/test/hmr/main.test.js +0 -121
- package/test/hmr/manifest.json +0 -3
- package/test/hmr/register.js +0 -1
- package/test/hmr/settings.js +0 -3
- package/test/html-relative-paths/index.html +0 -7
- package/test/html-relative-paths/index.js +0 -3
- package/test/html-relative-paths/main.test.js +0 -39
- package/test/html-relative-paths/other.html +0 -7
- package/test/html-relative-paths/style.css +0 -1
- package/test/manifest-dependencies/main.test.js +0 -26
- package/test/manifest-dependencies/manifest.json +0 -3
- package/test/manifest-dependencies/register.js +0 -3
- package/test/manifest-dependencies/style.less +0 -1
- package/test/manifest-dynamic-deps/main.test.js +0 -28
- package/test/manifest-dynamic-deps/manifest.json +0 -3
- package/test/manifest-dynamic-deps/register.js +0 -7
- package/test/manifest-dynamic-deps/some_dep.js +0 -5
- package/test/manifest-dynamic-deps/style.less +0 -1
- package/test/manifest-multiple/entry1.js +0 -1
- package/test/manifest-multiple/main.test.js +0 -83
- package/test/manifest-multiple/manifest.json +0 -7
- package/test/manifest-multiple/sub/entry2.js +0 -3
- package/test/manifest-multiple/sub/manifest.json +0 -4
- package/test/manifest-simple/main.test.js +0 -105
- package/test/manifest-simple/manifest.json +0 -3
- package/test/manifest-simple/register.js +0 -1
- package/test/meta/main.test.js +0 -25
- package/test/meta/manifest.json +0 -3
- package/test/meta/register.js +0 -1
- package/test/preload-helper-bundled/async.js +0 -1
- package/test/preload-helper-bundled/index.js +0 -1
- package/test/preload-helper-bundled/main.test.js +0 -32
- package/test/preload-helper-bundled/manifest.json +0 -4
- package/test/preload-helper-separate/bar.js +0 -1
- package/test/preload-helper-separate/foo.js +0 -3
- package/test/preload-helper-separate/index.js +0 -1
- package/test/preload-helper-separate/main.test.js +0 -34
- package/test/preload-helper-separate/manifest.json +0 -4
- package/test/settings-core/index.js +0 -4
- package/test/settings-core/main.test.js +0 -56
- package/test/settings-core/manifest.json +0 -4
- package/test/settings-core/no-settings.js +0 -3
- package/test/settings-core/settings.js +0 -3
- package/test/settings-external/index.js +0 -3
- package/test/settings-external/main.test.js +0 -61
- package/test/settings-external/manifest.json +0 -4
- package/test/settings-external/settings.js +0 -3
- package/test/settings-ts/index.js +0 -3
- package/test/settings-ts/main.test.js +0 -30
- package/test/settings-ts/manifest.json +0 -4
- package/test/settings-ts/settings.ts +0 -4
- package/test/settings-with-requirements/foo.js +0 -3
- package/test/settings-with-requirements/forth-settings.js +0 -3
- package/test/settings-with-requirements/index.js +0 -5
- package/test/settings-with-requirements/main.test.js +0 -95
- package/test/settings-with-requirements/manifest.json +0 -12
- package/test/settings-with-requirements/other-settings.js +0 -3
- package/test/settings-with-requirements/other.js +0 -4
- package/test/settings-with-requirements/settings.js +0 -3
- package/test/settings-with-requirements/third-settings.js +0 -3
- package/test/util/deep-merge.test.js +0 -59
- package/test/util.js +0 -16
|
@@ -1,71 +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('Multiple dictionaries gettext scenario', 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
|
-
i18n: 'i18n'
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
plugins: [rollupPluginPo2Json({
|
|
34
|
-
poFiles: __dirname + '/i18n/*.po'
|
|
35
|
-
}), vitePluginOxManifests({
|
|
36
|
-
|
|
37
|
-
})]
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
41
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
42
|
-
expect(Object.keys(manifests)).toHaveLength(10)
|
|
43
|
-
expect(manifests['register.js'].meta.manifests[0].namespace).toEqual('test')
|
|
44
|
-
expect(manifests['../../foobar.js'].meta.manifests[0].namespace).toEqual('i18n')
|
|
45
|
-
expect(manifests['../../i18n'].meta.manifests[0].namespace).toEqual('i18n')
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it('works in dev mode', async function () {
|
|
49
|
-
server = await createServer({
|
|
50
|
-
root: __dirname,
|
|
51
|
-
logLevel: 'silent',
|
|
52
|
-
plugins: [rollupPluginPo2Json({
|
|
53
|
-
poFiles: __dirname + '/i18n/*.po'
|
|
54
|
-
}), vitePluginOxManifests({
|
|
55
|
-
|
|
56
|
-
})]
|
|
57
|
-
})
|
|
58
|
-
await server.listen(PORT)
|
|
59
|
-
|
|
60
|
-
const res = await fetch(`http://localhost:${PORT}/api/manifest.json`)
|
|
61
|
-
const manifests = await res.json()
|
|
62
|
-
|
|
63
|
-
expect(manifests).toHaveLength(3)
|
|
64
|
-
expect(manifests[0].namespace).toEqual('i18n')
|
|
65
|
-
expect(manifests[0].path).toEqual('foobar')
|
|
66
|
-
expect(manifests[1].namespace).toEqual('i18n')
|
|
67
|
-
expect(manifests[1].path).toEqual('i18n')
|
|
68
|
-
expect(manifests[2].namespace).toEqual('test')
|
|
69
|
-
expect(manifests[2].path).toContain('register')
|
|
70
|
-
})
|
|
71
|
-
})
|
|
@@ -1,18 +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"
|
|
@@ -1,18 +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 ""
|
|
@@ -1,61 +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('Simple gettext scenario', 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: { write: false, rollupOptions: { input: {} } },
|
|
26
|
-
plugins: [rollupPluginPo2Json({
|
|
27
|
-
poFiles: __dirname + '/i18n/*.po'
|
|
28
|
-
}), vitePluginOxManifests({
|
|
29
|
-
|
|
30
|
-
})]
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
34
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
35
|
-
expect(Object.keys(manifests)).toHaveLength(5)
|
|
36
|
-
expect(manifests['register.js'].meta.manifests[0].namespace).toEqual('test')
|
|
37
|
-
expect(manifests['../../i18n.js'].meta.manifests[0].namespace).toEqual('i18n')
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it('works in dev mode', async function () {
|
|
41
|
-
server = await createServer({
|
|
42
|
-
root: __dirname,
|
|
43
|
-
logLevel: 'silent',
|
|
44
|
-
plugins: [rollupPluginPo2Json({
|
|
45
|
-
poFiles: __dirname + '/i18n/*.po'
|
|
46
|
-
}), vitePluginOxManifests({
|
|
47
|
-
|
|
48
|
-
})]
|
|
49
|
-
})
|
|
50
|
-
await server.listen(PORT)
|
|
51
|
-
|
|
52
|
-
const res = await fetch(`http://localhost:${PORT}/api/manifest.json`)
|
|
53
|
-
const manifests = await res.json()
|
|
54
|
-
|
|
55
|
-
expect(manifests).toHaveLength(2)
|
|
56
|
-
expect(manifests[0].namespace).toEqual('i18n')
|
|
57
|
-
expect(manifests[0].path).toContain('i18n')
|
|
58
|
-
expect(manifests[1].namespace).toEqual('test')
|
|
59
|
-
expect(manifests[1].path).toContain('register')
|
|
60
|
-
})
|
|
61
|
-
})
|
package/test/hmr/main.test.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, 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
|
-
import { readFileSync, writeFileSync } from 'fs'
|
|
7
|
-
import { waitForReload } from '../../src/util'
|
|
8
|
-
import vitePluginOxExternals from '@open-xchange/vite-plugin-ox-externals'
|
|
9
|
-
|
|
10
|
-
const __dirname = path.dirname(new URL(import.meta.url).pathname)
|
|
11
|
-
const files = ['register.js', 'settings.js']
|
|
12
|
-
const PORT = getPort()
|
|
13
|
-
|
|
14
|
-
describe('HMR', function () {
|
|
15
|
-
let server, data
|
|
16
|
-
|
|
17
|
-
beforeEach(function () {
|
|
18
|
-
data = files.map(f => readFileSync(path.join(__dirname, f)))
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
afterEach(async function () {
|
|
22
|
-
data.forEach((d, i) => writeFileSync(path.join(__dirname, files[i]), d))
|
|
23
|
-
data = null
|
|
24
|
-
await server?.close()
|
|
25
|
-
server = null
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it('adds timestamps to manifest files', async function () {
|
|
29
|
-
server = await createServer({
|
|
30
|
-
root: __dirname,
|
|
31
|
-
logLevel: 'silent',
|
|
32
|
-
plugins: [vitePluginOxManifests({
|
|
33
|
-
|
|
34
|
-
}), vitePluginOxExternals({
|
|
35
|
-
prefix: '$'
|
|
36
|
-
})]
|
|
37
|
-
})
|
|
38
|
-
await server.listen(PORT)
|
|
39
|
-
|
|
40
|
-
// fetch this file to start watcher
|
|
41
|
-
await fetch(`http://localhost:${PORT}/register.js`)
|
|
42
|
-
|
|
43
|
-
const manifests = await fetch(`http://localhost:${PORT}/manifests`).then(r => r.json())
|
|
44
|
-
expect(Object.keys(manifests)).toHaveLength(2)
|
|
45
|
-
expect(manifests[1]).not.toContain('raw')
|
|
46
|
-
|
|
47
|
-
writeFileSync(path.join(__dirname, 'register.js'), 'console.log("Changed")')
|
|
48
|
-
|
|
49
|
-
await waitForReload(server)
|
|
50
|
-
|
|
51
|
-
const manifestsWithHMR = await fetch(`http://localhost:${PORT}/manifests`).then(r => r.json())
|
|
52
|
-
expect(Object.keys(manifestsWithHMR)).toHaveLength(2)
|
|
53
|
-
expect(manifestsWithHMR[1].namespace).toEqual('test')
|
|
54
|
-
expect(manifestsWithHMR[1].raw).toMatch(/\/register\.js\?t=\d+/)
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
it('adds timestamps to settings manifest files', async function () {
|
|
58
|
-
server = await createServer({
|
|
59
|
-
root: __dirname,
|
|
60
|
-
logLevel: 'silent',
|
|
61
|
-
plugins: [vitePluginOxManifests({
|
|
62
|
-
|
|
63
|
-
}), vitePluginOxExternals({
|
|
64
|
-
prefix: '$'
|
|
65
|
-
})]
|
|
66
|
-
})
|
|
67
|
-
await server.listen(PORT)
|
|
68
|
-
|
|
69
|
-
// fetch this file to start watcher
|
|
70
|
-
await fetch(`http://localhost:${PORT}/settings.js`)
|
|
71
|
-
|
|
72
|
-
const manifests = await fetch(`http://localhost:${PORT}/manifests`).then(r => r.json())
|
|
73
|
-
expect(Object.keys(manifests)).toHaveLength(2)
|
|
74
|
-
expect(manifests[0]).not.toContain('raw')
|
|
75
|
-
|
|
76
|
-
writeFileSync(path.join(__dirname, 'settings.js'), `/* a comment */${data[1].toString()}`)
|
|
77
|
-
|
|
78
|
-
await waitForReload(server)
|
|
79
|
-
|
|
80
|
-
const manifestsWithHMR = await fetch(`http://localhost:${PORT}/manifests`).then(r => r.json())
|
|
81
|
-
expect(Object.keys(manifestsWithHMR)).toHaveLength(2)
|
|
82
|
-
expect(manifestsWithHMR[0].namespace).toEqual('settings')
|
|
83
|
-
expect(manifestsWithHMR[0].raw).toMatch(/\/settings\.js\?t=\d+/)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it('includes base-path in manifests', async function () {
|
|
87
|
-
server = await createServer({
|
|
88
|
-
root: __dirname,
|
|
89
|
-
logLevel: 'silent',
|
|
90
|
-
base: '/appsuite',
|
|
91
|
-
plugins: [vitePluginOxManifests({
|
|
92
|
-
|
|
93
|
-
}), vitePluginOxExternals({
|
|
94
|
-
prefix: '$'
|
|
95
|
-
})]
|
|
96
|
-
})
|
|
97
|
-
await server.listen(PORT)
|
|
98
|
-
|
|
99
|
-
// fetch this file to start watcher
|
|
100
|
-
await fetch(`http://localhost:${PORT}/appsuite/register.js`)
|
|
101
|
-
await fetch(`http://localhost:${PORT}/appsuite/settings.js`)
|
|
102
|
-
|
|
103
|
-
const manifests = await fetch(`http://localhost:${PORT}/appsuite/manifests`).then(r => r.json())
|
|
104
|
-
expect(Object.keys(manifests)).toHaveLength(2)
|
|
105
|
-
expect(manifests[0]).not.toContain('raw')
|
|
106
|
-
expect(manifests[1]).not.toContain('raw')
|
|
107
|
-
|
|
108
|
-
writeFileSync(path.join(__dirname, 'register.js'), 'console.log("Changed")')
|
|
109
|
-
await waitForReload(server)
|
|
110
|
-
|
|
111
|
-
writeFileSync(path.join(__dirname, 'settings.js'), `/* a comment */${data[1].toString()}`)
|
|
112
|
-
await waitForReload(server)
|
|
113
|
-
|
|
114
|
-
const manifestsWithHMR = await fetch(`http://localhost:${PORT}/appsuite/manifests`).then(r => r.json())
|
|
115
|
-
expect(Object.keys(manifestsWithHMR)).toHaveLength(2)
|
|
116
|
-
expect(manifestsWithHMR[0].namespace).toEqual('settings')
|
|
117
|
-
expect(manifestsWithHMR[0].raw).toMatch(/\/appsuite\/settings\.js\?t=\d+/)
|
|
118
|
-
expect(manifestsWithHMR[1].namespace).toEqual('test')
|
|
119
|
-
expect(manifestsWithHMR[1].raw).toMatch(/\/appsuite\/register\.js\?t=\d+/)
|
|
120
|
-
})
|
|
121
|
-
})
|
package/test/hmr/manifest.json
DELETED
package/test/hmr/register.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('Hello world!')
|
package/test/hmr/settings.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from '@jest/globals'
|
|
2
|
-
import { build } from 'vite'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import vitePluginOxManifests from '../../index'
|
|
5
|
-
import { getFileFromBundle } from '../util'
|
|
6
|
-
|
|
7
|
-
const __dirname = path.dirname(new URL(import.meta.url).pathname)
|
|
8
|
-
|
|
9
|
-
describe('HTML relative paths', function () {
|
|
10
|
-
it('transforms paths', async function () {
|
|
11
|
-
// keep this test here as reference. Transformation is now done via vite itself
|
|
12
|
-
const bundle = await build({
|
|
13
|
-
root: __dirname,
|
|
14
|
-
logLevel: 'silent',
|
|
15
|
-
base: './',
|
|
16
|
-
build: {
|
|
17
|
-
write: false,
|
|
18
|
-
rollupOptions: {
|
|
19
|
-
input: {
|
|
20
|
-
'index.html': path.join(__dirname, 'index.html'),
|
|
21
|
-
'other.html': path.join(__dirname, 'other.html')
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
const indexFile = getFileFromBundle('index.html', bundle)
|
|
28
|
-
expect(indexFile.source).toContain('src="./')
|
|
29
|
-
expect(indexFile.source).toContain('href="./')
|
|
30
|
-
expect(indexFile.source).not.toContain('src="/')
|
|
31
|
-
expect(indexFile.source).not.toContain('href="/')
|
|
32
|
-
|
|
33
|
-
const otherFile = getFileFromBundle('other.html', bundle)
|
|
34
|
-
expect(otherFile.source).toContain('src="./')
|
|
35
|
-
expect(otherFile.source).toContain('href="./')
|
|
36
|
-
expect(otherFile.source).not.toContain('src="/')
|
|
37
|
-
expect(otherFile.source).not.toContain('href="/')
|
|
38
|
-
})
|
|
39
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
body { background: green; }
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from '@jest/globals'
|
|
2
|
-
import { build } from 'vite'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import vitePluginOxManifests from '../../index'
|
|
5
|
-
import { getFileFromBundle } from '../util'
|
|
6
|
-
|
|
7
|
-
const __dirname = path.dirname(new URL(import.meta.url).pathname)
|
|
8
|
-
|
|
9
|
-
describe('Manifest with dependencies', function () {
|
|
10
|
-
it('works', async function () {
|
|
11
|
-
const bundle = await build({
|
|
12
|
-
root: __dirname,
|
|
13
|
-
logLevel: 'silent',
|
|
14
|
-
build: { write: false, rollupOptions: { input: {} } },
|
|
15
|
-
plugins: [vitePluginOxManifests({
|
|
16
|
-
|
|
17
|
-
})]
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
21
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
22
|
-
expect(Object.keys(manifests)).toHaveLength(2)
|
|
23
|
-
expect(manifests['register.js'].meta.manifests[0].namespace).toEqual('test')
|
|
24
|
-
expect(manifests['register.js'].css).toHaveLength(1)
|
|
25
|
-
})
|
|
26
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
body { color: red; }
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from '@jest/globals'
|
|
2
|
-
import { build } from 'vite'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import vitePluginOxManifests from '../../index'
|
|
5
|
-
import { getFileFromBundle } from '../util'
|
|
6
|
-
|
|
7
|
-
const __dirname = path.dirname(new URL(import.meta.url).pathname)
|
|
8
|
-
|
|
9
|
-
describe('Manifest with dynamic dependencies', function () {
|
|
10
|
-
it('works', async function () {
|
|
11
|
-
const bundle = await build({
|
|
12
|
-
root: __dirname,
|
|
13
|
-
logLevel: 'silent',
|
|
14
|
-
build: {
|
|
15
|
-
write: false,
|
|
16
|
-
rollupOptions: { input: {} }
|
|
17
|
-
},
|
|
18
|
-
plugins: [vitePluginOxManifests({
|
|
19
|
-
|
|
20
|
-
})]
|
|
21
|
-
})
|
|
22
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
23
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
24
|
-
|
|
25
|
-
expect(manifests['register.js'].css).toHaveLength(1)
|
|
26
|
-
expect(manifests['register.js'].dynamicImports).toHaveLength(1)
|
|
27
|
-
})
|
|
28
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
body { color: red; }
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('Hello world')
|
|
@@ -1,83 +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 vitePluginOxExternals from '@open-xchange/vite-plugin-ox-externals'
|
|
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('Multiple manifest scenario', 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: [vitePluginOxExternals({
|
|
32
|
-
prefix: '$'
|
|
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(2)
|
|
41
|
-
|
|
42
|
-
expect(manifests['entry1.js'].meta.manifests[0].namespace).toEqual('test')
|
|
43
|
-
|
|
44
|
-
expect(manifests['sub/entry2.js'].meta.manifests).toHaveLength(3)
|
|
45
|
-
expect(manifests['sub/entry2.js'].meta.manifests.find(m => m.namespace === 'other').namespace).toEqual('other')
|
|
46
|
-
expect(manifests['sub/entry2.js'].meta.manifests.find(m => m.namespace === 'test').namespace).toEqual('test')
|
|
47
|
-
expect(manifests['sub/entry2.js'].meta.manifests.find(m => m.namespace === 'settings').namespace).toEqual('settings')
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('works in dev mode', async function () {
|
|
51
|
-
server = await createServer({
|
|
52
|
-
root: __dirname,
|
|
53
|
-
logLevel: 'silent',
|
|
54
|
-
plugins: [vitePluginOxManifests({
|
|
55
|
-
|
|
56
|
-
}), vitePluginOxExternals({
|
|
57
|
-
prefix: '$'
|
|
58
|
-
})]
|
|
59
|
-
})
|
|
60
|
-
await server.listen(PORT)
|
|
61
|
-
|
|
62
|
-
const res = await fetch(`http://localhost:${PORT}/api/manifest.json`)
|
|
63
|
-
const manifests = await res.json()
|
|
64
|
-
|
|
65
|
-
expect(manifests).toHaveLength(4)
|
|
66
|
-
|
|
67
|
-
const entry1Index = manifests.findIndex(m => m.path.indexOf('entry1') >= 0)
|
|
68
|
-
expect(manifests[entry1Index].namespace).toEqual('test')
|
|
69
|
-
expect(manifests[entry1Index].path).toContain('entry1')
|
|
70
|
-
|
|
71
|
-
const otherNSIndex = manifests.findIndex(m => m.namespace === 'other')
|
|
72
|
-
expect(manifests[otherNSIndex].namespace).toEqual('other')
|
|
73
|
-
expect(manifests[otherNSIndex].path).toContain('entry2')
|
|
74
|
-
|
|
75
|
-
const lastIndex = manifests.findIndex(({ path, namespace }) => path.indexOf('entry2') >= 0 && namespace === 'test')
|
|
76
|
-
expect(manifests[lastIndex].namespace).toEqual('test')
|
|
77
|
-
expect(manifests[lastIndex].path).toContain('entry2')
|
|
78
|
-
|
|
79
|
-
const settingsIndex = manifests.findIndex(m => m.namespace === 'settings')
|
|
80
|
-
expect(manifests[settingsIndex].namespace).toEqual('settings')
|
|
81
|
-
expect(manifests[settingsIndex].path).toContain('entry2')
|
|
82
|
-
})
|
|
83
|
-
})
|