vite 2.6.0-beta.0 → 2.6.0-beta.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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

Files changed (110) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/LICENSE.md +161 -3011
  3. package/bin/vite.js +2 -1
  4. package/dist/node/chunks/{dep-91aa74e8.js → dep-1e0a75a8.js} +58 -32
  5. package/dist/node/chunks/dep-1e0a75a8.js.map +1 -0
  6. package/dist/node/chunks/{dep-e36486f6.js → dep-ac1b4bf9.js} +1 -1
  7. package/dist/node/chunks/dep-ac1b4bf9.js.map +1 -0
  8. package/dist/node/chunks/{dep-c7e510f9.js → dep-ba6b30a0.js} +27538 -4953
  9. package/dist/node/chunks/dep-ba6b30a0.js.map +1 -0
  10. package/dist/node/chunks/{dep-11213a75.js → dep-c4cf6e92.js} +19 -6
  11. package/dist/node/chunks/dep-c4cf6e92.js.map +1 -0
  12. package/dist/node/chunks/{dep-eb6ef720.js → dep-d574094c.js} +18 -5
  13. package/dist/node/chunks/dep-d574094c.js.map +1 -0
  14. package/dist/node/chunks/{dep-0d2f9464.js → dep-e39b05d6.js} +18 -5
  15. package/dist/node/chunks/dep-e39b05d6.js.map +1 -0
  16. package/dist/node/cli.js +60 -23992
  17. package/dist/node/cli.js.map +1 -1
  18. package/dist/node/index.d.ts +26 -8
  19. package/dist/node/index.js +18 -15
  20. package/dist/node/index.js.map +1 -1
  21. package/dist/node/terser.js +102 -55
  22. package/package.json +28 -13
  23. package/types/package.json +3 -0
  24. package/api-extractor.json +0 -54
  25. package/dist/node/chunks/dep-0d2f9464.js.map +0 -1
  26. package/dist/node/chunks/dep-11213a75.js.map +0 -1
  27. package/dist/node/chunks/dep-91aa74e8.js.map +0 -1
  28. package/dist/node/chunks/dep-c7e510f9.js.map +0 -1
  29. package/dist/node/chunks/dep-e36486f6.js.map +0 -1
  30. package/dist/node/chunks/dep-eb6ef720.js.map +0 -1
  31. package/dist/node/terser.js.map +0 -1
  32. package/rollup.config.js +0 -389
  33. package/scripts/patchTypes.js +0 -70
  34. package/src/node/__tests__/asset.spec.ts +0 -156
  35. package/src/node/__tests__/build.spec.ts +0 -67
  36. package/src/node/__tests__/config.spec.ts +0 -166
  37. package/src/node/__tests__/packages/name/package.json +0 -3
  38. package/src/node/__tests__/packages/noname/package.json +0 -1
  39. package/src/node/__tests__/plugins/css.spec.ts +0 -116
  40. package/src/node/__tests__/scan.spec.ts +0 -118
  41. package/src/node/__tests__/utils.spec.ts +0 -40
  42. package/src/node/build.ts +0 -783
  43. package/src/node/cli.ts +0 -239
  44. package/src/node/config.ts +0 -1033
  45. package/src/node/constants.ts +0 -87
  46. package/src/node/importGlob.ts +0 -173
  47. package/src/node/index.ts +0 -88
  48. package/src/node/logger.ts +0 -167
  49. package/src/node/optimizer/esbuildDepPlugin.ts +0 -216
  50. package/src/node/optimizer/index.ts +0 -410
  51. package/src/node/optimizer/registerMissing.ts +0 -102
  52. package/src/node/optimizer/scan.ts +0 -457
  53. package/src/node/plugin.ts +0 -138
  54. package/src/node/plugins/asset.ts +0 -365
  55. package/src/node/plugins/assetImportMetaUrl.ts +0 -99
  56. package/src/node/plugins/clientInjections.ts +0 -72
  57. package/src/node/plugins/css.ts +0 -1279
  58. package/src/node/plugins/dataUri.ts +0 -64
  59. package/src/node/plugins/define.ts +0 -107
  60. package/src/node/plugins/esbuild.ts +0 -280
  61. package/src/node/plugins/html.ts +0 -673
  62. package/src/node/plugins/importAnalysis.ts +0 -614
  63. package/src/node/plugins/importAnalysisBuild.ts +0 -334
  64. package/src/node/plugins/index.ts +0 -69
  65. package/src/node/plugins/json.ts +0 -75
  66. package/src/node/plugins/loadFallback.ts +0 -19
  67. package/src/node/plugins/manifest.ts +0 -123
  68. package/src/node/plugins/modulePreloadPolyfill.ts +0 -100
  69. package/src/node/plugins/preAlias.ts +0 -22
  70. package/src/node/plugins/reporter.ts +0 -244
  71. package/src/node/plugins/resolve.ts +0 -925
  72. package/src/node/plugins/terser.ts +0 -40
  73. package/src/node/plugins/wasm.ts +0 -72
  74. package/src/node/plugins/worker.ts +0 -117
  75. package/src/node/preview.ts +0 -82
  76. package/src/node/server/__tests__/fixtures/none/nested/package.json +0 -3
  77. package/src/node/server/__tests__/fixtures/pnpm/nested/package.json +0 -3
  78. package/src/node/server/__tests__/fixtures/pnpm/package.json +0 -3
  79. package/src/node/server/__tests__/fixtures/pnpm/pnpm-workspace.yaml +0 -0
  80. package/src/node/server/__tests__/fixtures/yarn/nested/package.json +0 -3
  81. package/src/node/server/__tests__/fixtures/yarn/package.json +0 -6
  82. package/src/node/server/__tests__/search-root.spec.ts +0 -31
  83. package/src/node/server/hmr.ts +0 -489
  84. package/src/node/server/http.ts +0 -198
  85. package/src/node/server/index.ts +0 -705
  86. package/src/node/server/middlewares/base.ts +0 -52
  87. package/src/node/server/middlewares/error.ts +0 -98
  88. package/src/node/server/middlewares/indexHtml.ts +0 -170
  89. package/src/node/server/middlewares/proxy.ts +0 -124
  90. package/src/node/server/middlewares/spaFallback.ts +0 -32
  91. package/src/node/server/middlewares/static.ts +0 -153
  92. package/src/node/server/middlewares/time.ts +0 -18
  93. package/src/node/server/middlewares/transform.ts +0 -196
  94. package/src/node/server/moduleGraph.ts +0 -200
  95. package/src/node/server/openBrowser.ts +0 -101
  96. package/src/node/server/pluginContainer.ts +0 -546
  97. package/src/node/server/searchRoot.ts +0 -70
  98. package/src/node/server/send.ts +0 -54
  99. package/src/node/server/sourcemap.ts +0 -54
  100. package/src/node/server/transformRequest.ts +0 -168
  101. package/src/node/server/ws.ts +0 -131
  102. package/src/node/ssr/__tests__/ssrTransform.spec.ts +0 -309
  103. package/src/node/ssr/ssrExternal.ts +0 -161
  104. package/src/node/ssr/ssrManifestPlugin.ts +0 -53
  105. package/src/node/ssr/ssrModuleLoader.ts +0 -214
  106. package/src/node/ssr/ssrStacktrace.ts +0 -75
  107. package/src/node/ssr/ssrTransform.ts +0 -452
  108. package/src/node/tsconfig.json +0 -14
  109. package/src/node/utils.ts +0 -565
  110. package/tsconfig.base.json +0 -11
@@ -1,166 +0,0 @@
1
- import { InlineConfig } from '..'
2
- import {
3
- mergeConfig,
4
- resolveConfig,
5
- UserConfigExport,
6
- resolveEnvPrefix,
7
- UserConfig
8
- } from '../config'
9
-
10
- describe('mergeConfig', () => {
11
- test('handles configs with different alias schemas', () => {
12
- const baseConfig: UserConfigExport = {
13
- resolve: {
14
- alias: [
15
- {
16
- find: 'foo',
17
- replacement: 'foo-value'
18
- }
19
- ]
20
- }
21
- }
22
-
23
- const newConfig: UserConfigExport = {
24
- resolve: {
25
- alias: {
26
- bar: 'bar-value',
27
- baz: 'baz-value'
28
- }
29
- }
30
- }
31
-
32
- const mergedConfig: UserConfigExport = {
33
- resolve: {
34
- alias: [
35
- {
36
- find: 'foo',
37
- replacement: 'foo-value'
38
- },
39
- {
40
- find: 'bar',
41
- replacement: 'bar-value'
42
- },
43
- {
44
- find: 'baz',
45
- replacement: 'baz-value'
46
- }
47
- ]
48
- }
49
- }
50
-
51
- expect(mergeConfig(baseConfig, newConfig)).toEqual(mergedConfig)
52
- })
53
-
54
- test('handles assetsInclude', () => {
55
- const baseConfig: UserConfigExport = {
56
- assetsInclude: 'some-string'
57
- }
58
-
59
- const newConfig: UserConfigExport = {
60
- assetsInclude: ['some-other-string', /regexp?/]
61
- }
62
-
63
- const mergedConfig: UserConfigExport = {
64
- assetsInclude: ['some-string', 'some-other-string', /regexp?/]
65
- }
66
-
67
- expect(mergeConfig(baseConfig, newConfig)).toEqual(mergedConfig)
68
- })
69
-
70
- test('not handles alias not under `resolve`', () => {
71
- const baseConfig = {
72
- custom: {
73
- alias: {
74
- bar: 'bar-value',
75
- baz: 'baz-value'
76
- }
77
- }
78
- }
79
-
80
- const newConfig = {
81
- custom: {
82
- alias: {
83
- bar: 'bar-value-2',
84
- foo: 'foo-value'
85
- }
86
- }
87
- }
88
-
89
- const mergedConfig = {
90
- custom: {
91
- alias: {
92
- bar: 'bar-value-2',
93
- baz: 'baz-value',
94
- foo: 'foo-value'
95
- }
96
- }
97
- }
98
-
99
- expect(mergeConfig(baseConfig, newConfig)).toEqual(mergedConfig)
100
- })
101
- })
102
-
103
- describe('resolveConfig', () => {
104
- beforeAll(() => {
105
- // silence deprecation warning
106
- jest.spyOn(console, 'warn').mockImplementation(() => {})
107
- })
108
-
109
- afterAll(() => {
110
- jest.clearAllMocks()
111
- })
112
-
113
- test('copies optimizeDeps.keepNames to esbuildOptions.keepNames', async () => {
114
- const config: InlineConfig = {
115
- optimizeDeps: {
116
- keepNames: false
117
- }
118
- }
119
-
120
- expect(await resolveConfig(config, 'serve')).toMatchObject({
121
- optimizeDeps: {
122
- esbuildOptions: {
123
- keepNames: false
124
- }
125
- }
126
- })
127
- })
128
-
129
- test('uses esbuildOptions.keepNames if set', async () => {
130
- const config: InlineConfig = {
131
- optimizeDeps: {
132
- keepNames: true,
133
- esbuildOptions: {
134
- keepNames: false
135
- }
136
- }
137
- }
138
-
139
- expect(await resolveConfig(config, 'serve')).toMatchObject({
140
- optimizeDeps: {
141
- esbuildOptions: {
142
- keepNames: false
143
- }
144
- }
145
- })
146
- })
147
- })
148
-
149
- describe('resolveEnvPrefix', () => {
150
- test(`use 'VITE_' as default value`, () => {
151
- const config: UserConfig = {}
152
- expect(resolveEnvPrefix(config)).toMatchObject(['VITE_'])
153
- })
154
-
155
- test(`throw error if envPrefix contains ''`, () => {
156
- let config: UserConfig = { envPrefix: '' }
157
- expect(() => resolveEnvPrefix(config)).toThrow()
158
- config = { envPrefix: ['', 'CUSTOM_'] }
159
- expect(() => resolveEnvPrefix(config)).toThrow()
160
- })
161
-
162
- test('should work correctly for valid envPrefix value', () => {
163
- const config: UserConfig = { envPrefix: [' ', 'CUSTOM_'] }
164
- expect(resolveEnvPrefix(config)).toMatchObject([' ', 'CUSTOM_'])
165
- })
166
- })
@@ -1,3 +0,0 @@
1
- {
2
- "name": "mylib"
3
- }
@@ -1,116 +0,0 @@
1
- import { cssUrlRE, cssPlugin } from '../../plugins/css'
2
- import { resolveConfig } from '../../config'
3
- import fs from 'fs'
4
- import path from 'path'
5
-
6
- describe('search css url function', () => {
7
- test('some spaces before it', () => {
8
- expect(
9
- cssUrlRE.test("list-style-image: url('../images/bullet.jpg');")
10
- ).toBe(true)
11
- })
12
-
13
- test('no space after colon', () => {
14
- expect(cssUrlRE.test("list-style-image:url('../images/bullet.jpg');")).toBe(
15
- true
16
- )
17
- })
18
-
19
- test('at the beginning of line', () => {
20
- expect(cssUrlRE.test("url('../images/bullet.jpg');")).toBe(true)
21
- })
22
-
23
- test('as suffix of a function name', () => {
24
- expect(
25
- cssUrlRE.test(`@function svg-url($string) {
26
- @return "";
27
- }`)
28
- ).toBe(false)
29
- })
30
-
31
- test('after parenthesis', () => {
32
- expect(
33
- cssUrlRE.test(
34
- 'mask-image: image(url(mask.png), skyblue, linear-gradient(rgba(0, 0, 0, 1.0), transparent));'
35
- )
36
- ).toBe(true)
37
- })
38
-
39
- test('after comma', () => {
40
- expect(
41
- cssUrlRE.test(
42
- 'mask-image: image(skyblue,url(mask.png), linear-gradient(rgba(0, 0, 0, 1.0), transparent));'
43
- )
44
- ).toBe(true)
45
- })
46
- })
47
-
48
- describe('css path resolutions', () => {
49
- const mockedProjectPath = path.join(process.cwd(), '/foo/bar/project')
50
- const mockedBarCssRelativePath = '/css/bar.module.css'
51
- const mockedFooCssRelativePath = '/css/foo.module.css'
52
-
53
- test('cssmodule compose/from path resolutions', async () => {
54
- const config = await resolveConfig(
55
- {
56
- resolve: {
57
- alias: [
58
- {
59
- find: '@',
60
- replacement: mockedProjectPath
61
- }
62
- ]
63
- }
64
- },
65
- 'serve'
66
- )
67
-
68
- const { transform, buildStart } = cssPlugin(config)
69
-
70
- await buildStart.call({})
71
-
72
- const mockFs = jest
73
- .spyOn(fs, 'readFile')
74
- // @ts-ignore jest.spyOn not recognize overrided `fs.readFile` definition.
75
- .mockImplementationOnce((p, encoding, callback) => {
76
- expect(p).toBe(path.join(mockedProjectPath, mockedBarCssRelativePath))
77
- expect(encoding).toBe('utf-8')
78
- callback(
79
- null,
80
- Buffer.from(`
81
- .bar {
82
- display: block;
83
- background: #f0f;
84
- }
85
- `)
86
- )
87
- })
88
-
89
- const { code } = await transform.call(
90
- {
91
- addWatchFile() {
92
- return
93
- }
94
- },
95
- `
96
- .foo {
97
- position: fixed;
98
- composes: bar from '@${mockedBarCssRelativePath}';
99
- }
100
- `,
101
- path.join(mockedProjectPath, mockedFooCssRelativePath)
102
- )
103
-
104
- expect(code).toBe(`
105
- ._bar_soicv_2 {
106
- display: block;
107
- background: #f0f;
108
- }
109
- ._foo_sctn3_2 {
110
- position: fixed;
111
- }
112
- `)
113
-
114
- mockFs.mockReset()
115
- })
116
- })
@@ -1,118 +0,0 @@
1
- import { scriptRE, commentRE, importsRE } from '../optimizer/scan'
2
- import { multilineCommentsRE, singlelineCommentsRE } from '../utils'
3
-
4
- describe('optimizer-scan:script-test', () => {
5
- const scriptContent = `import { defineComponent } from 'vue'
6
- import ScriptDevelopPane from './ScriptDevelopPane.vue';
7
- export default defineComponent({
8
- components: {
9
- ScriptDevelopPane
10
- }
11
- })`
12
-
13
- test('component return value test', () => {
14
- scriptRE.lastIndex = 0
15
- const [, tsOpenTag, tsContent] = scriptRE.exec(
16
- `<script lang="ts">${scriptContent}</script>`
17
- )
18
- expect(tsOpenTag).toEqual('<script lang="ts">')
19
- expect(tsContent).toEqual(scriptContent)
20
-
21
- scriptRE.lastIndex = 0
22
- const [, openTag, content] = scriptRE.exec(
23
- `<script>${scriptContent}</script>`
24
- )
25
- expect(openTag).toEqual('<script>')
26
- expect(content).toEqual(scriptContent)
27
- })
28
-
29
- test('include comments test', () => {
30
- scriptRE.lastIndex = 0
31
- const ret = scriptRE.exec(
32
- `<template>
33
- <!-- <script >var test = null</script> -->
34
- </template>`.replace(commentRE, '')
35
- )
36
- expect(ret).toEqual(null)
37
- })
38
-
39
- test('components with script keyword test', () => {
40
- scriptRE.lastIndex = 0
41
- let ret = scriptRE.exec(`<template><script-develop-pane/></template>`)
42
- expect(ret).toBe(null)
43
-
44
- scriptRE.lastIndex = 0
45
- ret = scriptRE.exec(
46
- `<template><script-develop-pane></script-develop-pane></template>`
47
- )
48
- expect(ret).toBe(null)
49
-
50
- scriptRE.lastIndex = 0
51
- ret = scriptRE.exec(
52
- `<template><script-develop-pane > content </script-develop-pane></template>`
53
- )
54
- expect(ret).toBe(null)
55
- })
56
-
57
- test('ordinary script tag test', () => {
58
- scriptRE.lastIndex = 0
59
- const [, tag, content] = scriptRE.exec(`<script >var test = null</script>`)
60
- expect(tag).toEqual('<script >')
61
- expect(content).toEqual('var test = null')
62
-
63
- scriptRE.lastIndex = 0
64
- const [, tag1, content1] = scriptRE.exec(`<script>var test = null</script>`)
65
- expect(tag1).toEqual('<script>')
66
- expect(content1).toEqual('var test = null')
67
- })
68
-
69
- test('imports regex should work', () => {
70
- const shouldMatchArray = [
71
- `import 'vue'`,
72
- `import { foo } from 'vue'`,
73
- `import foo from 'vue'`,
74
- `;import foo from 'vue'`,
75
- ` import foo from 'vue'`,
76
- `import { foo
77
- } from 'vue'`,
78
- `import bar, { foo } from 'vue'`,
79
- `import foo from 'vue';`,
80
- `*/ import foo from 'vue';`,
81
- `import foo from 'vue';//comment`,
82
- `import foo from 'vue';/*comment
83
- */`
84
- // Skipped, false negatives with current regex
85
- // `import typescript from 'typescript'`,
86
- // import type, {foo} from 'vue'
87
- ]
88
-
89
- shouldMatchArray.forEach((str) => {
90
- importsRE.lastIndex = 0
91
- expect(importsRE.exec(str)[1]).toEqual("'vue'")
92
- })
93
-
94
- const shouldFailArray = [
95
- `testMultiline("import", {
96
- body: "ok" });`,
97
- `//;import foo from 'vue'`,
98
- `import type { Bar } from 'foo'`,
99
- `import type{ Bar } from 'foo'`,
100
- `import type Bar from 'foo'`
101
- ]
102
- shouldFailArray.forEach((str) => {
103
- expect(importsRE.test(str)).toBe(false)
104
- })
105
- })
106
-
107
- test('script comments test', () => {
108
- multilineCommentsRE.lastIndex = 0
109
- let ret = `/*
110
- export default { }
111
- */`.replace(multilineCommentsRE, '')
112
- expect(ret).not.toContain('export default')
113
-
114
- singlelineCommentsRE.lastIndex = 0
115
- ret = `//export default { }`.replace(singlelineCommentsRE, '')
116
- expect(ret).not.toContain('export default')
117
- })
118
- })
@@ -1,40 +0,0 @@
1
- import { injectQuery, isWindows } from '../utils'
2
-
3
- if (isWindows) {
4
- // this test will work incorrectly on unix systems
5
- test('normalize windows path', () => {
6
- expect(injectQuery('C:\\User\\Vite\\Project', 'direct')).toEqual(
7
- 'C:/User/Vite/Project?direct'
8
- )
9
- })
10
- }
11
-
12
- test('path with multiple spaces', () => {
13
- expect(injectQuery('/usr/vite/path with space', 'direct')).toEqual(
14
- '/usr/vite/path with space?direct'
15
- )
16
- })
17
-
18
- test('path with multiple % characters', () => {
19
- expect(injectQuery('/usr/vite/not%20a%20space', 'direct')).toEqual(
20
- '/usr/vite/not%20a%20space?direct'
21
- )
22
- })
23
-
24
- test('path with %25', () => {
25
- expect(injectQuery('/usr/vite/%25hello%25', 'direct')).toEqual(
26
- '/usr/vite/%25hello%25?direct'
27
- )
28
- })
29
-
30
- test('path with unicode', () => {
31
- expect(injectQuery('/usr/vite/東京', 'direct')).toEqual(
32
- '/usr/vite/東京?direct'
33
- )
34
- })
35
-
36
- test('path with unicode, space, and %', () => {
37
- expect(injectQuery('/usr/vite/東京 %20 hello', 'direct')).toEqual(
38
- '/usr/vite/東京 %20 hello?direct'
39
- )
40
- })