@open-xchange/vite-plugin-ox-manifests 0.5.2 → 0.5.4
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 +27 -0
- package/coverage/clover.xml +348 -0
- package/coverage/coverage-final.json +11 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +161 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/vite-plugin-ox-manifests/index.html +116 -0
- package/coverage/lcov-report/vite-plugin-ox-manifests/index.js.html +601 -0
- package/coverage/lcov-report/vite-plugin-ox-manifests/src/constants.js.html +88 -0
- package/coverage/lcov-report/vite-plugin-ox-manifests/src/index.html +131 -0
- package/coverage/lcov-report/vite-plugin-ox-manifests/src/plugins/gettext.js.html +292 -0
- package/coverage/lcov-report/vite-plugin-ox-manifests/src/plugins/index.html +191 -0
- package/coverage/lcov-report/vite-plugin-ox-manifests/src/plugins/manifests.js.html +493 -0
- package/coverage/lcov-report/vite-plugin-ox-manifests/src/plugins/meta.js.html +124 -0
- package/coverage/lcov-report/vite-plugin-ox-manifests/src/plugins/relative-paths.js.html +97 -0
- package/coverage/lcov-report/vite-plugin-ox-manifests/src/plugins/serve.js.html +277 -0
- package/coverage/lcov-report/vite-plugin-ox-manifests/src/plugins/settings.js.html +526 -0
- package/coverage/lcov-report/vite-plugin-ox-manifests/src/util.js.html +268 -0
- package/coverage/lcov.info +748 -0
- package/package.json +11 -19
- package/src/plugins/relative-paths.js +0 -3
- package/.eslintrc.cjs +0 -10
- package/.gitlab-ci.yml +0 -26
- 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,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
|
-
})
|
|
@@ -1,105 +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 { getFileFromBundle, getPort } from '../util'
|
|
6
|
-
|
|
7
|
-
const __dirname = path.dirname(new URL(import.meta.url).pathname)
|
|
8
|
-
const PORT = getPort()
|
|
9
|
-
|
|
10
|
-
describe('Simple manifest scenario', function () {
|
|
11
|
-
let server
|
|
12
|
-
|
|
13
|
-
afterEach(async function () {
|
|
14
|
-
if (server) {
|
|
15
|
-
await server.close()
|
|
16
|
-
server = null
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it('works', async function () {
|
|
21
|
-
const bundle = await build({
|
|
22
|
-
root: __dirname,
|
|
23
|
-
logLevel: 'silent',
|
|
24
|
-
build: { write: false, rollupOptions: { input: {} } },
|
|
25
|
-
plugins: [vitePluginOxManifests({
|
|
26
|
-
|
|
27
|
-
})]
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
31
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
32
|
-
expect(Object.keys(manifests)).toHaveLength(1)
|
|
33
|
-
expect(manifests['register.js'].meta.manifests[0].namespace).toEqual('test')
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('works in dev mode', async function () {
|
|
37
|
-
server = await createServer({
|
|
38
|
-
root: __dirname,
|
|
39
|
-
logLevel: 'silent',
|
|
40
|
-
plugins: [vitePluginOxManifests({
|
|
41
|
-
|
|
42
|
-
})]
|
|
43
|
-
})
|
|
44
|
-
await server.listen(PORT)
|
|
45
|
-
|
|
46
|
-
const res = await fetch(`http://localhost:${PORT}/api/manifest.json`)
|
|
47
|
-
const manifests = await res.json()
|
|
48
|
-
|
|
49
|
-
expect(Object.keys(manifests)).toHaveLength(1)
|
|
50
|
-
expect(manifests[0].namespace).toEqual('test')
|
|
51
|
-
expect(manifests[0].path).toContain('register')
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('works in dev mode with base set', async function () {
|
|
55
|
-
server = await createServer({
|
|
56
|
-
root: __dirname,
|
|
57
|
-
base: '/appsuite/',
|
|
58
|
-
logLevel: 'silent',
|
|
59
|
-
plugins: [vitePluginOxManifests({
|
|
60
|
-
|
|
61
|
-
})]
|
|
62
|
-
})
|
|
63
|
-
await server.listen(PORT)
|
|
64
|
-
|
|
65
|
-
const res = await fetch(`http://localhost:${PORT}/appsuite/api/manifest.json`)
|
|
66
|
-
const manifests = await res.json()
|
|
67
|
-
|
|
68
|
-
expect(Object.keys(manifests)).toHaveLength(1)
|
|
69
|
-
expect(manifests[0].namespace).toEqual('test')
|
|
70
|
-
expect(manifests[0].path).toContain('register')
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
it('works in dev mode with base set (new endpoint)', async function () {
|
|
74
|
-
server = await createServer({
|
|
75
|
-
root: __dirname,
|
|
76
|
-
base: '/appsuite/',
|
|
77
|
-
logLevel: 'silent',
|
|
78
|
-
plugins: [vitePluginOxManifests({
|
|
79
|
-
|
|
80
|
-
})]
|
|
81
|
-
})
|
|
82
|
-
await server.listen(PORT)
|
|
83
|
-
|
|
84
|
-
const res = await fetch(`http://localhost:${PORT}/appsuite/manifests`)
|
|
85
|
-
const manifests = await res.json()
|
|
86
|
-
|
|
87
|
-
expect(Object.keys(manifests)).toHaveLength(1)
|
|
88
|
-
expect(manifests[0].namespace).toEqual('test')
|
|
89
|
-
expect(manifests[0].path).toContain('register')
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
it('does not empty files on transform', async function () {
|
|
93
|
-
server = await createServer({
|
|
94
|
-
root: __dirname,
|
|
95
|
-
logLevel: 'silent',
|
|
96
|
-
plugins: [vitePluginOxManifests({
|
|
97
|
-
|
|
98
|
-
})]
|
|
99
|
-
})
|
|
100
|
-
await server.listen(PORT)
|
|
101
|
-
|
|
102
|
-
const res = await fetch(`http://localhost:${PORT}/register.js`)
|
|
103
|
-
expect(await res.text()).toEqual("console.log('Hello world')\n")
|
|
104
|
-
})
|
|
105
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('Hello world')
|
package/test/meta/main.test.js
DELETED
|
@@ -1,25 +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('Meta option', 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
|
-
meta: {
|
|
17
|
-
version: '1.2.3'
|
|
18
|
-
}
|
|
19
|
-
})]
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
const metaFile = getFileFromBundle('meta.json', bundle)
|
|
23
|
-
expect(JSON.parse(metaFile.source)).toEqual({ version: '1.2.3' })
|
|
24
|
-
})
|
|
25
|
-
})
|
package/test/meta/manifest.json
DELETED
package/test/meta/register.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('Hello world')
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(() => import('./async'))()
|
|
@@ -1,32 +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
|
-
describe('Preload helper bundled', function () {
|
|
8
|
-
it('works', async function () {
|
|
9
|
-
const bundle = await build({
|
|
10
|
-
root: path.dirname(new URL(import.meta.url).pathname),
|
|
11
|
-
logLevel: 'silent',
|
|
12
|
-
build: {
|
|
13
|
-
minify: false,
|
|
14
|
-
write: false,
|
|
15
|
-
rollupOptions: {
|
|
16
|
-
input: {}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
plugins: [vitePluginOxManifests({
|
|
20
|
-
|
|
21
|
-
})]
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const index = getFileFromBundle('index', bundle)
|
|
25
|
-
expect(index.code).toContain('const __vitePreload = function preload')
|
|
26
|
-
|
|
27
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
28
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
29
|
-
expect(Object.keys(manifests)).toHaveLength(2)
|
|
30
|
-
expect(manifests['index.js'].dependencies).toBeUndefined()
|
|
31
|
-
})
|
|
32
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(() => import('./foo'))()
|
|
@@ -1,34 +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('Preload helper separate', function () {
|
|
10
|
-
it('replaces code for relative path loading', async function () {
|
|
11
|
-
const bundle = await build({
|
|
12
|
-
root: __dirname,
|
|
13
|
-
logLevel: 'silent',
|
|
14
|
-
build: {
|
|
15
|
-
minify: false,
|
|
16
|
-
write: false,
|
|
17
|
-
rollupOptions: {
|
|
18
|
-
input: {}
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
plugins: [vitePluginOxManifests({
|
|
22
|
-
entryPoints: [`${__dirname}/{foo,bar}.js`]
|
|
23
|
-
})]
|
|
24
|
-
})
|
|
25
|
-
const preloadHelper = getFileFromBundle('preload', bundle)
|
|
26
|
-
expect(preloadHelper.code).toContain('const __vitePreload = function preload')
|
|
27
|
-
|
|
28
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
29
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
30
|
-
expect(Object.keys(manifests)).toHaveLength(4)
|
|
31
|
-
expect(manifests['index.js'].imports).toHaveLength(1)
|
|
32
|
-
expect(manifests['index.js'].imports[0]).toContain('preload-helper')
|
|
33
|
-
})
|
|
34
|
-
})
|
|
@@ -1,56 +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 { getFileFromBundle, getPort } from '../util'
|
|
6
|
-
|
|
7
|
-
const PORT = getPort()
|
|
8
|
-
|
|
9
|
-
describe('Settings like in core', function () {
|
|
10
|
-
let server
|
|
11
|
-
|
|
12
|
-
afterEach(async function () {
|
|
13
|
-
if (server) {
|
|
14
|
-
await server.close()
|
|
15
|
-
server = null
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('works', async function () {
|
|
20
|
-
const bundle = await build({
|
|
21
|
-
root: path.dirname(new URL(import.meta.url).pathname),
|
|
22
|
-
logLevel: 'silent',
|
|
23
|
-
build: {
|
|
24
|
-
write: false,
|
|
25
|
-
rollupOptions: {
|
|
26
|
-
input: {},
|
|
27
|
-
external: ['@/io.ox/core/settings']
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
plugins: [vitePluginOxManifests({
|
|
31
|
-
|
|
32
|
-
})]
|
|
33
|
-
})
|
|
34
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
35
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
36
|
-
expect(Object.keys(manifests)).toHaveLength(2)
|
|
37
|
-
expect(manifests['settings.js'].meta.manifests[0].namespace).toEqual('settings')
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it('works in dev mode', async function () {
|
|
41
|
-
server = await createServer({
|
|
42
|
-
root: path.dirname(new URL(import.meta.url).pathname),
|
|
43
|
-
logLevel: 'silent',
|
|
44
|
-
plugins: [vitePluginOxManifests({
|
|
45
|
-
|
|
46
|
-
})]
|
|
47
|
-
})
|
|
48
|
-
await server.listen(PORT)
|
|
49
|
-
|
|
50
|
-
const res = await fetch(`http://localhost:${PORT}/api/manifest.json`)
|
|
51
|
-
const manifests = await res.json()
|
|
52
|
-
|
|
53
|
-
expect(manifests).toHaveLength(2)
|
|
54
|
-
expect(manifests[0].namespace).toEqual('settings')
|
|
55
|
-
})
|
|
56
|
-
})
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from '@jest/globals'
|
|
2
|
-
import { build, createServer } from 'vite'
|
|
3
|
-
import vitePluginOxExternals from '@open-xchange/vite-plugin-ox-externals'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import vitePluginOxManifests from '../../index'
|
|
6
|
-
import { getFileFromBundle, getPort } from '../util'
|
|
7
|
-
|
|
8
|
-
const PORT = getPort()
|
|
9
|
-
|
|
10
|
-
describe('Settings external', function () {
|
|
11
|
-
let server
|
|
12
|
-
|
|
13
|
-
afterEach(async function () {
|
|
14
|
-
if (server) {
|
|
15
|
-
await server.close()
|
|
16
|
-
server = null
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it('works', async function () {
|
|
21
|
-
const bundle = await build({
|
|
22
|
-
root: path.dirname(new URL(import.meta.url).pathname),
|
|
23
|
-
logLevel: 'silent',
|
|
24
|
-
build: {
|
|
25
|
-
write: false,
|
|
26
|
-
rollupOptions: {
|
|
27
|
-
input: {}
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
plugins: [vitePluginOxManifests({
|
|
31
|
-
|
|
32
|
-
}), vitePluginOxExternals({
|
|
33
|
-
prefix: '$'
|
|
34
|
-
})]
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
38
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
39
|
-
expect(Object.keys(manifests)).toHaveLength(2)
|
|
40
|
-
expect(manifests['settings.js'].meta.manifests[0].namespace).toEqual('settings')
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('works in dev mode', async function () {
|
|
44
|
-
server = await createServer({
|
|
45
|
-
root: path.dirname(new URL(import.meta.url).pathname),
|
|
46
|
-
logLevel: 'silent',
|
|
47
|
-
plugins: [vitePluginOxManifests({
|
|
48
|
-
|
|
49
|
-
}), vitePluginOxExternals({
|
|
50
|
-
prefix: '$'
|
|
51
|
-
})]
|
|
52
|
-
})
|
|
53
|
-
await server.listen(PORT)
|
|
54
|
-
|
|
55
|
-
const res = await fetch(`http://localhost:${PORT}/api/manifest.json`)
|
|
56
|
-
const manifests = await res.json()
|
|
57
|
-
|
|
58
|
-
expect(manifests).toHaveLength(2)
|
|
59
|
-
expect(manifests[0].namespace).toEqual('settings')
|
|
60
|
-
})
|
|
61
|
-
})
|