vite 3.0.0-alpha.2 → 3.0.0-alpha.5
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/dist/node/chunks/{dep-c15b7842.js → dep-0232e200.js} +36297 -35993
- package/dist/node/chunks/{dep-df464a73.js → dep-13a14c32.js} +100 -47
- package/dist/node/chunks/{dep-24157481.js → dep-17430d09.js} +0 -0
- package/dist/node/chunks/{dep-c6d28e94.js → dep-21067347.js} +1 -1
- package/dist/node/chunks/{dep-205b15fe.js → dep-cd161504.js} +2 -2
- package/dist/node/cli.js +14 -16
- package/dist/node/config.d.ts +7 -4
- package/dist/node/constants.js +1 -1
- package/dist/node/env.d.ts +3 -0
- package/dist/node/index.d.ts +40 -13
- package/dist/node/index.js +2 -2
- package/dist/node/optimizer/index.d.ts +33 -6
- package/dist/node/optimizer/optimizer.d.ts +4 -0
- package/dist/node/plugin.d.ts +1 -0
- package/dist/node/plugins/optimizedDeps.d.ts +4 -1
- package/dist/node/plugins/preAlias.d.ts +2 -1
- package/dist/node/plugins/resolve.d.ts +5 -3
- package/dist/node/publicUtils.d.ts +1 -0
- package/dist/node/server/index.d.ts +0 -9
- package/dist/node/utils.d.ts +1 -2
- package/dist/node-cjs/publicUtils.cjs +288 -40
- package/package.json +9 -8
- package/dist/node/optimizer/registerMissing.d.ts +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { x as getAugmentedNamespace, y as getDefaultExportFromCjs } from './dep-0232e200.js';
|
|
2
2
|
|
|
3
3
|
import { fileURLToPath as __cjs_fileURLToPath } from 'url';
|
|
4
4
|
import { dirname as __cjs_dirname } from 'path';
|
|
@@ -424,6 +424,11 @@ function looseEqual(a, b) {
|
|
|
424
424
|
if (aValidType || bValidType) {
|
|
425
425
|
return aValidType && bValidType ? a.getTime() === b.getTime() : false;
|
|
426
426
|
}
|
|
427
|
+
aValidType = isSymbol(a);
|
|
428
|
+
bValidType = isSymbol(b);
|
|
429
|
+
if (aValidType || bValidType) {
|
|
430
|
+
return a === b;
|
|
431
|
+
}
|
|
427
432
|
aValidType = isArray(a);
|
|
428
433
|
bValidType = isArray(b);
|
|
429
434
|
if (aValidType || bValidType) {
|
|
@@ -520,7 +525,7 @@ const hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
|
520
525
|
const isArray = Array.isArray;
|
|
521
526
|
const isMap = (val) => toTypeString(val) === '[object Map]';
|
|
522
527
|
const isSet = (val) => toTypeString(val) === '[object Set]';
|
|
523
|
-
const isDate = (val) => val
|
|
528
|
+
const isDate = (val) => toTypeString(val) === '[object Date]';
|
|
524
529
|
const isFunction = (val) => typeof val === 'function';
|
|
525
530
|
const isString = (val) => typeof val === 'string';
|
|
526
531
|
const isSymbol = (val) => typeof val === 'symbol';
|
|
@@ -604,7 +609,13 @@ const getGlobalThis = () => {
|
|
|
604
609
|
: typeof global !== 'undefined'
|
|
605
610
|
? global
|
|
606
611
|
: {}));
|
|
607
|
-
};
|
|
612
|
+
};
|
|
613
|
+
const identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
|
|
614
|
+
function genPropsAccessExp(name) {
|
|
615
|
+
return identRE.test(name)
|
|
616
|
+
? `__props.${name}`
|
|
617
|
+
: `__props[${JSON.stringify(name)}]`;
|
|
618
|
+
}
|
|
608
619
|
|
|
609
620
|
var shared_esmBundler = {
|
|
610
621
|
__proto__: null,
|
|
@@ -619,6 +630,7 @@ var shared_esmBundler = {
|
|
|
619
630
|
escapeHtml: escapeHtml,
|
|
620
631
|
escapeHtmlComment: escapeHtmlComment,
|
|
621
632
|
extend: extend,
|
|
633
|
+
genPropsAccessExp: genPropsAccessExp,
|
|
622
634
|
generateCodeFrame: generateCodeFrame,
|
|
623
635
|
getGlobalThis: getGlobalThis,
|
|
624
636
|
hasChanged: hasChanged,
|
|
@@ -2452,6 +2464,14 @@ function getConstantType(node, context) {
|
|
|
2452
2464
|
// static then they don't need to be blocks since there will be no
|
|
2453
2465
|
// nested updates.
|
|
2454
2466
|
if (codegenNode.isBlock) {
|
|
2467
|
+
// except set custom directives.
|
|
2468
|
+
for (let i = 0; i < node.props.length; i++) {
|
|
2469
|
+
const p = node.props[i];
|
|
2470
|
+
if (p.type === 7 /* DIRECTIVE */) {
|
|
2471
|
+
constantCache.set(node, 0 /* NOT_CONSTANT */);
|
|
2472
|
+
return 0 /* NOT_CONSTANT */;
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2455
2475
|
context.removeHelper(OPEN_BLOCK);
|
|
2456
2476
|
context.removeHelper(getVNodeBlockHelper(context.inSSR, codegenNode.isComponent));
|
|
2457
2477
|
codegenNode.isBlock = false;
|
|
@@ -2858,6 +2878,7 @@ function createStructuralDirectiveTransform(name, fn) {
|
|
|
2858
2878
|
}
|
|
2859
2879
|
|
|
2860
2880
|
const PURE_ANNOTATION = `/*#__PURE__*/`;
|
|
2881
|
+
const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
2861
2882
|
function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssrRuntimeModuleName = 'vue/server-renderer', ssr = false, isTS = false, inSSR = false }) {
|
|
2862
2883
|
const context = {
|
|
2863
2884
|
mode,
|
|
@@ -2934,9 +2955,7 @@ function generate(ast, options = {}) {
|
|
|
2934
2955
|
// function mode const declarations should be inside with block
|
|
2935
2956
|
// also they should be renamed to avoid collision with user properties
|
|
2936
2957
|
if (hasHelpers) {
|
|
2937
|
-
push(`const { ${ast.helpers
|
|
2938
|
-
.map(s => `${helperNameMap[s]}: _${helperNameMap[s]}`)
|
|
2939
|
-
.join(', ')} } = _Vue`);
|
|
2958
|
+
push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
|
|
2940
2959
|
push(`\n`);
|
|
2941
2960
|
newline();
|
|
2942
2961
|
}
|
|
@@ -2996,7 +3015,6 @@ function generate(ast, options = {}) {
|
|
|
2996
3015
|
function genFunctionPreamble(ast, context) {
|
|
2997
3016
|
const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName, ssrRuntimeModuleName } = context;
|
|
2998
3017
|
const VueBinding = runtimeGlobalName;
|
|
2999
|
-
const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
3000
3018
|
// Generate const declaration for helpers
|
|
3001
3019
|
// In prefix mode, we place the const declaration at top so it's done
|
|
3002
3020
|
// only once; But if we not prefixing, we place the declaration inside the
|
|
@@ -3714,14 +3732,14 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3714
3732
|
}
|
|
3715
3733
|
}
|
|
3716
3734
|
function createIfBranch(node, dir) {
|
|
3735
|
+
const isTemplateIf = node.tagType === 3 /* TEMPLATE */;
|
|
3717
3736
|
return {
|
|
3718
3737
|
type: 10 /* IF_BRANCH */,
|
|
3719
3738
|
loc: node.loc,
|
|
3720
3739
|
condition: dir.name === 'else' ? undefined : dir.exp,
|
|
3721
|
-
children:
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
userKey: findProp(node, `key`)
|
|
3740
|
+
children: isTemplateIf && !findDir(node, 'for') ? node.children : [node],
|
|
3741
|
+
userKey: findProp(node, `key`),
|
|
3742
|
+
isTemplateIf
|
|
3725
3743
|
};
|
|
3726
3744
|
}
|
|
3727
3745
|
function createCodegenNodeForBranch(branch, keyIndex, context) {
|
|
@@ -3757,6 +3775,7 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
|
3757
3775
|
// check if the fragment actually contains a single valid child with
|
|
3758
3776
|
// the rest being comments
|
|
3759
3777
|
if ((process.env.NODE_ENV !== 'production') &&
|
|
3778
|
+
!branch.isTemplateIf &&
|
|
3760
3779
|
children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
|
|
3761
3780
|
patchFlag |= 2048 /* DEV_ROOT_FRAGMENT */;
|
|
3762
3781
|
patchFlagText += `, ${PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
|
|
@@ -4333,7 +4352,7 @@ const transformElement = (node, context) => {
|
|
|
4333
4352
|
(tag === 'svg' || tag === 'foreignObject'));
|
|
4334
4353
|
// props
|
|
4335
4354
|
if (props.length > 0) {
|
|
4336
|
-
const propsBuildResult = buildProps(node, context);
|
|
4355
|
+
const propsBuildResult = buildProps(node, context, undefined, isComponent, isDynamicComponent);
|
|
4337
4356
|
vnodeProps = propsBuildResult.props;
|
|
4338
4357
|
patchFlag = propsBuildResult.patchFlag;
|
|
4339
4358
|
dynamicPropNames = propsBuildResult.dynamicPropNames;
|
|
@@ -4475,9 +4494,8 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
4475
4494
|
context.components.add(tag);
|
|
4476
4495
|
return toValidAssetId(tag, `component`);
|
|
4477
4496
|
}
|
|
4478
|
-
function buildProps(node, context, props = node.props, ssr = false) {
|
|
4497
|
+
function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
|
|
4479
4498
|
const { tag, loc: elementLoc, children } = node;
|
|
4480
|
-
const isComponent = node.tagType === 1 /* COMPONENT */;
|
|
4481
4499
|
let properties = [];
|
|
4482
4500
|
const mergeArgs = [];
|
|
4483
4501
|
const runtimeDirectives = [];
|
|
@@ -4496,8 +4514,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
4496
4514
|
if (isStaticExp(key)) {
|
|
4497
4515
|
const name = key.content;
|
|
4498
4516
|
const isEventHandler = isOn(name);
|
|
4499
|
-
if (
|
|
4500
|
-
|
|
4517
|
+
if (isEventHandler &&
|
|
4518
|
+
(!isComponent || isDynamicComponent) &&
|
|
4501
4519
|
// omit the flag for click handlers because hydration gives click
|
|
4502
4520
|
// dedicated fast path.
|
|
4503
4521
|
name.toLowerCase() !== 'onclick' &&
|
|
@@ -4752,10 +4770,11 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
4752
4770
|
classProp.value = createCallExpression(context.helper(NORMALIZE_CLASS), [classProp.value]);
|
|
4753
4771
|
}
|
|
4754
4772
|
if (styleProp &&
|
|
4755
|
-
!isStaticExp(styleProp.value) &&
|
|
4756
4773
|
// the static style is compiled into an object,
|
|
4757
4774
|
// so use `hasStyleBinding` to ensure that it is a dynamic style binding
|
|
4758
4775
|
(hasStyleBinding ||
|
|
4776
|
+
(styleProp.value.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
4777
|
+
styleProp.value.content.trim()[0] === `[`) ||
|
|
4759
4778
|
// v-bind:style and style both exist,
|
|
4760
4779
|
// v-bind:style with static literal object
|
|
4761
4780
|
styleProp.value.type === 17 /* JS_ARRAY_EXPRESSION */)) {
|
|
@@ -4953,7 +4972,7 @@ function processSlotOutlet(node, context) {
|
|
|
4953
4972
|
}
|
|
4954
4973
|
}
|
|
4955
4974
|
if (nonNameProps.length > 0) {
|
|
4956
|
-
const { props, directives } = buildProps(node, context, nonNameProps);
|
|
4975
|
+
const { props, directives } = buildProps(node, context, nonNameProps, false, false);
|
|
4957
4976
|
slotProps = props;
|
|
4958
4977
|
if (directives.length) {
|
|
4959
4978
|
context.onError(createCompilerError(36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
|
|
@@ -5124,11 +5143,7 @@ const transformText = (node, context) => {
|
|
|
5124
5143
|
const next = children[j];
|
|
5125
5144
|
if (isText(next)) {
|
|
5126
5145
|
if (!currentContainer) {
|
|
5127
|
-
currentContainer = children[i] =
|
|
5128
|
-
type: 8 /* COMPOUND_EXPRESSION */,
|
|
5129
|
-
loc: child.loc,
|
|
5130
|
-
children: [child]
|
|
5131
|
-
};
|
|
5146
|
+
currentContainer = children[i] = createCompoundExpression([child], child.loc);
|
|
5132
5147
|
}
|
|
5133
5148
|
// merge adjacent text node into current
|
|
5134
5149
|
currentContainer.children.push(` + `, next);
|
|
@@ -5597,6 +5612,7 @@ var compilerCore_esmBundler = {
|
|
|
5597
5612
|
findProp: findProp,
|
|
5598
5613
|
generate: generate,
|
|
5599
5614
|
getBaseTransformPreset: getBaseTransformPreset,
|
|
5615
|
+
getConstantType: getConstantType,
|
|
5600
5616
|
getInnerRange: getInnerRange,
|
|
5601
5617
|
getMemoedVNodeCall: getMemoedVNodeCall,
|
|
5602
5618
|
getVNodeBlockHelper: getVNodeBlockHelper,
|
|
@@ -8178,7 +8194,9 @@ const transformVText = (dir, node, context) => {
|
|
|
8178
8194
|
return {
|
|
8179
8195
|
props: [
|
|
8180
8196
|
compilerCore.createObjectProperty(compilerCore.createSimpleExpression(`textContent`, true), exp
|
|
8181
|
-
? compilerCore.
|
|
8197
|
+
? compilerCore.getConstantType(exp, context) > 0
|
|
8198
|
+
? exp
|
|
8199
|
+
: compilerCore.createCallExpression(context.helperString(compilerCore.TO_DISPLAY_STRING), [exp], loc)
|
|
8182
8200
|
: compilerCore.createSimpleExpression('', true))
|
|
8183
8201
|
]
|
|
8184
8202
|
};
|
|
@@ -8390,19 +8408,38 @@ const transformShow = (dir, node, context) => {
|
|
|
8390
8408
|
};
|
|
8391
8409
|
};
|
|
8392
8410
|
|
|
8393
|
-
const
|
|
8411
|
+
const transformTransition = (node, context) => {
|
|
8394
8412
|
if (node.type === 1 /* ELEMENT */ &&
|
|
8395
8413
|
node.tagType === 1 /* COMPONENT */) {
|
|
8396
8414
|
const component = context.isBuiltInComponent(node.tag);
|
|
8397
8415
|
if (component === TRANSITION) {
|
|
8398
8416
|
return () => {
|
|
8399
|
-
if (node.children.length
|
|
8417
|
+
if (!node.children.length) {
|
|
8418
|
+
return;
|
|
8419
|
+
}
|
|
8420
|
+
// warn multiple transition children
|
|
8421
|
+
if (hasMultipleChildren(node)) {
|
|
8400
8422
|
context.onError(createDOMCompilerError(59 /* X_TRANSITION_INVALID_CHILDREN */, {
|
|
8401
8423
|
start: node.children[0].loc.start,
|
|
8402
8424
|
end: node.children[node.children.length - 1].loc.end,
|
|
8403
8425
|
source: ''
|
|
8404
8426
|
}));
|
|
8405
8427
|
}
|
|
8428
|
+
// check if it's s single child w/ v-show
|
|
8429
|
+
// if yes, inject "persisted: true" to the transition props
|
|
8430
|
+
const child = node.children[0];
|
|
8431
|
+
if (child.type === 1 /* ELEMENT */) {
|
|
8432
|
+
for (const p of child.props) {
|
|
8433
|
+
if (p.type === 7 /* DIRECTIVE */ && p.name === 'show') {
|
|
8434
|
+
node.props.push({
|
|
8435
|
+
type: 6 /* ATTRIBUTE */,
|
|
8436
|
+
name: 'persisted',
|
|
8437
|
+
value: undefined,
|
|
8438
|
+
loc: node.loc
|
|
8439
|
+
});
|
|
8440
|
+
}
|
|
8441
|
+
}
|
|
8442
|
+
}
|
|
8406
8443
|
};
|
|
8407
8444
|
}
|
|
8408
8445
|
}
|
|
@@ -8618,6 +8655,7 @@ function stringifyNode(node, context) {
|
|
|
8618
8655
|
}
|
|
8619
8656
|
function stringifyElement(node, context) {
|
|
8620
8657
|
let res = `<${node.tag}`;
|
|
8658
|
+
let innerHTML = '';
|
|
8621
8659
|
for (let i = 0; i < node.props.length; i++) {
|
|
8622
8660
|
const p = node.props[i];
|
|
8623
8661
|
if (p.type === 6 /* ATTRIBUTE */) {
|
|
@@ -8626,25 +8664,35 @@ function stringifyElement(node, context) {
|
|
|
8626
8664
|
res += `="${shared.escapeHtml(p.value.content)}"`;
|
|
8627
8665
|
}
|
|
8628
8666
|
}
|
|
8629
|
-
else if (p.type === 7 /* DIRECTIVE */
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
// constant v-bind, e.g. :foo="1"
|
|
8638
|
-
let evaluated = evaluateConstant(exp);
|
|
8639
|
-
if (evaluated != null) {
|
|
8640
|
-
const arg = p.arg && p.arg.content;
|
|
8641
|
-
if (arg === 'class') {
|
|
8642
|
-
evaluated = shared.normalizeClass(evaluated);
|
|
8667
|
+
else if (p.type === 7 /* DIRECTIVE */) {
|
|
8668
|
+
if (p.name === 'bind') {
|
|
8669
|
+
const exp = p.exp;
|
|
8670
|
+
if (exp.content[0] === '_') {
|
|
8671
|
+
// internally generated string constant references
|
|
8672
|
+
// e.g. imported URL strings via compiler-sfc transformAssetUrl plugin
|
|
8673
|
+
res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
|
|
8674
|
+
continue;
|
|
8643
8675
|
}
|
|
8644
|
-
|
|
8645
|
-
|
|
8676
|
+
// constant v-bind, e.g. :foo="1"
|
|
8677
|
+
let evaluated = evaluateConstant(exp);
|
|
8678
|
+
if (evaluated != null) {
|
|
8679
|
+
const arg = p.arg && p.arg.content;
|
|
8680
|
+
if (arg === 'class') {
|
|
8681
|
+
evaluated = shared.normalizeClass(evaluated);
|
|
8682
|
+
}
|
|
8683
|
+
else if (arg === 'style') {
|
|
8684
|
+
evaluated = shared.stringifyStyle(shared.normalizeStyle(evaluated));
|
|
8685
|
+
}
|
|
8686
|
+
res += ` ${p.arg.content}="${shared.escapeHtml(evaluated)}"`;
|
|
8646
8687
|
}
|
|
8647
|
-
|
|
8688
|
+
}
|
|
8689
|
+
else if (p.name === 'html') {
|
|
8690
|
+
// #5439 v-html with constant value
|
|
8691
|
+
// not sure why would anyone do this but it can happen
|
|
8692
|
+
innerHTML = evaluateConstant(p.exp);
|
|
8693
|
+
}
|
|
8694
|
+
else if (p.name === 'text') {
|
|
8695
|
+
innerHTML = shared.escapeHtml(shared.toDisplayString(evaluateConstant(p.exp)));
|
|
8648
8696
|
}
|
|
8649
8697
|
}
|
|
8650
8698
|
}
|
|
@@ -8652,8 +8700,13 @@ function stringifyElement(node, context) {
|
|
|
8652
8700
|
res += ` ${context.scopeId}`;
|
|
8653
8701
|
}
|
|
8654
8702
|
res += `>`;
|
|
8655
|
-
|
|
8656
|
-
res +=
|
|
8703
|
+
if (innerHTML) {
|
|
8704
|
+
res += innerHTML;
|
|
8705
|
+
}
|
|
8706
|
+
else {
|
|
8707
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
8708
|
+
res += stringifyNode(node.children[i], context);
|
|
8709
|
+
}
|
|
8657
8710
|
}
|
|
8658
8711
|
if (!shared.isVoidTag(node.tag)) {
|
|
8659
8712
|
res += `</${node.tag}>`;
|
|
@@ -8666,7 +8719,7 @@ function stringifyElement(node, context) {
|
|
|
8666
8719
|
// here, e.g. `{{ 1 }}` or `{{ 'foo' }}`
|
|
8667
8720
|
// in addition, constant exps bail on presence of parens so you can't even
|
|
8668
8721
|
// run JSFuck in here. But we mark it unsafe for security review purposes.
|
|
8669
|
-
// (see compiler-core/src/
|
|
8722
|
+
// (see compiler-core/src/transforms/transformExpression)
|
|
8670
8723
|
function evaluateConstant(exp) {
|
|
8671
8724
|
if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
8672
8725
|
return new Function(`return ${exp.content}`)();
|
|
@@ -8703,7 +8756,7 @@ const ignoreSideEffectTags = (node, context) => {
|
|
|
8703
8756
|
|
|
8704
8757
|
const DOMNodeTransforms = [
|
|
8705
8758
|
transformStyle,
|
|
8706
|
-
...([
|
|
8759
|
+
...([transformTransition] )
|
|
8707
8760
|
];
|
|
8708
8761
|
const DOMDirectiveTransforms = {
|
|
8709
8762
|
cloak: compilerCore.noopDirectiveTransform,
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { w as commonjsGlobal } from './dep-0232e200.js';
|
|
2
2
|
import require$$1 from 'crypto';
|
|
3
3
|
import 'fs';
|
|
4
4
|
import 'path';
|
|
@@ -6,7 +6,6 @@ import 'url';
|
|
|
6
6
|
import 'perf_hooks';
|
|
7
7
|
import 'module';
|
|
8
8
|
import 'tty';
|
|
9
|
-
import 'os';
|
|
10
9
|
import 'esbuild';
|
|
11
10
|
import 'events';
|
|
12
11
|
import 'assert';
|
|
@@ -15,6 +14,7 @@ import 'util';
|
|
|
15
14
|
import 'net';
|
|
16
15
|
import 'http';
|
|
17
16
|
import 'stream';
|
|
17
|
+
import 'os';
|
|
18
18
|
import 'child_process';
|
|
19
19
|
import '../constants.js';
|
|
20
20
|
import 'buffer';
|
package/dist/node/cli.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { performance } from 'perf_hooks';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import {
|
|
3
|
+
import { v as colors, j as createLogger, e as resolveConfig } from './chunks/dep-0232e200.js';
|
|
4
4
|
import { VERSION } from './constants.js';
|
|
5
5
|
import 'fs';
|
|
6
6
|
import 'path';
|
|
7
7
|
import 'url';
|
|
8
8
|
import 'module';
|
|
9
9
|
import 'tty';
|
|
10
|
-
import 'os';
|
|
11
10
|
import 'esbuild';
|
|
12
11
|
import 'assert';
|
|
13
12
|
import 'resolve';
|
|
@@ -15,6 +14,7 @@ import 'util';
|
|
|
15
14
|
import 'net';
|
|
16
15
|
import 'http';
|
|
17
16
|
import 'stream';
|
|
17
|
+
import 'os';
|
|
18
18
|
import 'child_process';
|
|
19
19
|
import 'crypto';
|
|
20
20
|
import 'buffer';
|
|
@@ -682,7 +682,7 @@ cli
|
|
|
682
682
|
.action(async (root, options) => {
|
|
683
683
|
// output structure is preserved even after bundling so require()
|
|
684
684
|
// is ok here
|
|
685
|
-
const { createServer } = await import('./chunks/dep-
|
|
685
|
+
const { createServer } = await import('./chunks/dep-0232e200.js').then(function (n) { return n.B; });
|
|
686
686
|
try {
|
|
687
687
|
const server = await createServer({
|
|
688
688
|
root,
|
|
@@ -698,17 +698,13 @@ cli
|
|
|
698
698
|
}
|
|
699
699
|
await server.listen();
|
|
700
700
|
const info = server.config.logger.info;
|
|
701
|
-
info(colors.cyan(`\n vite v${VERSION}`) +
|
|
702
|
-
colors.green(` dev server running at:\n`), {
|
|
703
|
-
clear: !server.config.logger.hasWarned
|
|
704
|
-
});
|
|
705
|
-
server.printUrls();
|
|
706
701
|
// @ts-ignore
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
}
|
|
702
|
+
const viteStartTime = global.__vite_start_time ?? false;
|
|
703
|
+
const startupDurationString = viteStartTime
|
|
704
|
+
? colors.dim(`ready in ${colors.white(colors.bold(Math.ceil(performance.now() - viteStartTime)))} ms`)
|
|
705
|
+
: '';
|
|
706
|
+
info(`\n ${colors.green(`${colors.bold('VITE')} v${VERSION}`)} ${startupDurationString}\n`, { clear: !server.config.logger.hasWarned });
|
|
707
|
+
server.printUrls();
|
|
712
708
|
}
|
|
713
709
|
catch (e) {
|
|
714
710
|
createLogger(options.logLevel).error(colors.red(`error when starting dev server:\n${e.stack}`), { error: e });
|
|
@@ -728,10 +724,11 @@ cli
|
|
|
728
724
|
`or specify minifier to use (default: esbuild)`)
|
|
729
725
|
.option('--manifest [name]', `[boolean | string] emit build manifest json`)
|
|
730
726
|
.option('--ssrManifest [name]', `[boolean | string] emit ssr manifest json`)
|
|
727
|
+
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle (experimental)`)
|
|
731
728
|
.option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
|
|
732
729
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
733
730
|
.action(async (root, options) => {
|
|
734
|
-
const { build } = await import('./chunks/dep-
|
|
731
|
+
const { build } = await import('./chunks/dep-0232e200.js').then(function (n) { return n.A; });
|
|
735
732
|
const buildOptions = cleanOptions(options);
|
|
736
733
|
try {
|
|
737
734
|
await build({
|
|
@@ -741,6 +738,7 @@ cli
|
|
|
741
738
|
configFile: options.config,
|
|
742
739
|
logLevel: options.logLevel,
|
|
743
740
|
clearScreen: options.clearScreen,
|
|
741
|
+
force: options.force,
|
|
744
742
|
build: buildOptions
|
|
745
743
|
});
|
|
746
744
|
}
|
|
@@ -754,7 +752,7 @@ cli
|
|
|
754
752
|
.command('optimize [root]', 'pre-bundle dependencies')
|
|
755
753
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
756
754
|
.action(async (root, options) => {
|
|
757
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
|
755
|
+
const { optimizeDeps } = await import('./chunks/dep-0232e200.js').then(function (n) { return n.z; });
|
|
758
756
|
try {
|
|
759
757
|
const config = await resolveConfig({
|
|
760
758
|
root,
|
|
@@ -777,7 +775,7 @@ cli
|
|
|
777
775
|
.option('--https', `[boolean] use TLS + HTTP/2`)
|
|
778
776
|
.option('--open [path]', `[boolean | string] open browser on startup`)
|
|
779
777
|
.action(async (root, options) => {
|
|
780
|
-
const { preview } = await import('./chunks/dep-
|
|
778
|
+
const { preview } = await import('./chunks/dep-0232e200.js').then(function (n) { return n.C; });
|
|
781
779
|
try {
|
|
782
780
|
const server = await preview({
|
|
783
781
|
root,
|
package/dist/node/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Alias, AliasOptions } from 'types/alias';
|
|
2
2
|
import type { RollupOptions } from 'rollup';
|
|
3
3
|
import type { Plugin } from './plugin';
|
|
4
|
-
import type { BuildOptions } from './build';
|
|
4
|
+
import type { BuildOptions, ResolvedBuildOptions } from './build';
|
|
5
5
|
import type { ResolvedServerOptions, ServerOptions } from './server';
|
|
6
6
|
import type { PreviewOptions, ResolvedPreviewOptions } from './preview';
|
|
7
7
|
import type { CSSOptions } from './plugins/css';
|
|
@@ -11,7 +11,6 @@ import type { LogLevel, Logger } from './logger';
|
|
|
11
11
|
import type { DepOptimizationOptions } from './optimizer';
|
|
12
12
|
import type { JsonOptions } from './plugins/json';
|
|
13
13
|
import type { PackageCache } from './packages';
|
|
14
|
-
import type { ResolvedBuildOptions } from '.';
|
|
15
14
|
export interface ConfigEnv {
|
|
16
15
|
command: 'build' | 'serve';
|
|
17
16
|
mode: string;
|
|
@@ -106,6 +105,11 @@ export interface UserConfig {
|
|
|
106
105
|
* Preview specific options, e.g. host, port, https...
|
|
107
106
|
*/
|
|
108
107
|
preview?: PreviewOptions;
|
|
108
|
+
/**
|
|
109
|
+
* Force dep pre-optimization regardless of whether deps have changed.
|
|
110
|
+
* @experimental
|
|
111
|
+
*/
|
|
112
|
+
force?: boolean;
|
|
109
113
|
/**
|
|
110
114
|
* Dep optimization options
|
|
111
115
|
*/
|
|
@@ -239,5 +243,4 @@ export declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: st
|
|
|
239
243
|
config: UserConfig;
|
|
240
244
|
dependencies: string[];
|
|
241
245
|
} | null>;
|
|
242
|
-
export declare function
|
|
243
|
-
export declare function resolveEnvPrefix({ envPrefix }: UserConfig): string[];
|
|
246
|
+
export declare function isDepsOptimizerEnabled(config: ResolvedConfig): boolean;
|
package/dist/node/constants.js
CHANGED
package/dist/node/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ import type * as net from 'net';
|
|
|
23
23
|
import type { OutgoingHttpHeaders } from 'http';
|
|
24
24
|
import type { OutputBundle } from 'rollup';
|
|
25
25
|
import type { OutputChunk } from 'rollup';
|
|
26
|
+
import { parse } from 'es-module-lexer';
|
|
26
27
|
import type { PartialResolvedId } from 'rollup';
|
|
27
28
|
import type { Plugin as Plugin_3 } from 'rollup';
|
|
28
29
|
import type { PluginContext } from 'rollup';
|
|
@@ -543,6 +544,12 @@ export declare interface DepOptimizationOptions {
|
|
|
543
544
|
* cannot be globs).
|
|
544
545
|
*/
|
|
545
546
|
exclude?: string[];
|
|
547
|
+
/**
|
|
548
|
+
* Force ESM interop when importing for these dependencies. Some legacy
|
|
549
|
+
* packages advertise themselves as ESM but use `require` internally
|
|
550
|
+
* @experimental
|
|
551
|
+
*/
|
|
552
|
+
needsInterop?: string[];
|
|
546
553
|
/**
|
|
547
554
|
* Options to pass to esbuild during the dep scanning and optimization
|
|
548
555
|
*
|
|
@@ -566,11 +573,13 @@ export declare interface DepOptimizationOptions {
|
|
|
566
573
|
*/
|
|
567
574
|
extensions?: string[];
|
|
568
575
|
/**
|
|
569
|
-
* Disables dependencies optimizations
|
|
576
|
+
* Disables dependencies optimizations, true disables the optimizer during
|
|
577
|
+
* build and dev. Pass 'build' or 'dev' to only disable the optimizer in
|
|
578
|
+
* one of the modes. Deps optimization is enabled by default in both
|
|
570
579
|
* @default false
|
|
571
580
|
* @experimental
|
|
572
581
|
*/
|
|
573
|
-
disabled?: boolean;
|
|
582
|
+
disabled?: boolean | 'build' | 'dev';
|
|
574
583
|
}
|
|
575
584
|
|
|
576
585
|
export declare interface DepOptimizationProcessing {
|
|
@@ -589,6 +598,17 @@ export declare interface DepOptimizationResult {
|
|
|
589
598
|
cancel: () => void;
|
|
590
599
|
}
|
|
591
600
|
|
|
601
|
+
export declare interface DepsOptimizer {
|
|
602
|
+
metadata: DepOptimizationMetadata;
|
|
603
|
+
scanProcessing?: Promise<void>;
|
|
604
|
+
registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
|
|
605
|
+
run: () => void;
|
|
606
|
+
isOptimizedDepFile: (id: string) => boolean;
|
|
607
|
+
isOptimizedDepUrl: (url: string) => boolean;
|
|
608
|
+
getOptimizedDepId: (depInfo: OptimizedDepInfo) => string;
|
|
609
|
+
options: DepOptimizationOptions;
|
|
610
|
+
}
|
|
611
|
+
|
|
592
612
|
export declare interface ErrorPayload {
|
|
593
613
|
type: 'error'
|
|
594
614
|
err: {
|
|
@@ -629,6 +649,11 @@ export declare interface ExperimentalOptions {
|
|
|
629
649
|
importGlobRestoreExtension?: boolean;
|
|
630
650
|
}
|
|
631
651
|
|
|
652
|
+
export declare type ExportsData = ReturnType<typeof parse> & {
|
|
653
|
+
hasReExports?: true;
|
|
654
|
+
jsxLoader?: true;
|
|
655
|
+
};
|
|
656
|
+
|
|
632
657
|
export declare interface FileSystemServeOptions {
|
|
633
658
|
/**
|
|
634
659
|
* Strictly restrict file accessing outside of allowing paths.
|
|
@@ -1130,8 +1155,11 @@ export declare interface InternalResolveOptions extends ResolveOptions {
|
|
|
1130
1155
|
isFromTsImporter?: boolean;
|
|
1131
1156
|
tryEsmOnly?: boolean;
|
|
1132
1157
|
scan?: boolean;
|
|
1158
|
+
getDepsOptimizer?: () => DepsOptimizer | undefined;
|
|
1133
1159
|
}
|
|
1134
1160
|
|
|
1161
|
+
export declare function isDepsOptimizerEnabled(config: ResolvedConfig): boolean;
|
|
1162
|
+
|
|
1135
1163
|
export declare interface JsonOptions {
|
|
1136
1164
|
/**
|
|
1137
1165
|
* Generate a named export for every property of the JSON object
|
|
@@ -1281,12 +1309,11 @@ export declare interface OptimizedDepInfo {
|
|
|
1281
1309
|
* but the bundles may not yet be saved to disk
|
|
1282
1310
|
*/
|
|
1283
1311
|
processing?: Promise<void>;
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
|
|
1312
|
+
/**
|
|
1313
|
+
* ExportData cache, discovered deps will parse the src entry to get exports
|
|
1314
|
+
* data used both to define if interop is needed and when pre-bundling
|
|
1315
|
+
*/
|
|
1316
|
+
exportsData?: Promise<ExportsData>;
|
|
1290
1317
|
}
|
|
1291
1318
|
|
|
1292
1319
|
/**
|
|
@@ -1800,10 +1827,6 @@ export declare interface SendOptions {
|
|
|
1800
1827
|
export declare type ServerHook = (server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
|
|
1801
1828
|
|
|
1802
1829
|
export declare interface ServerOptions extends CommonServerOptions {
|
|
1803
|
-
/**
|
|
1804
|
-
* Force dep pre-optimization regardless of whether deps have changed.
|
|
1805
|
-
*/
|
|
1806
|
-
force?: boolean;
|
|
1807
1830
|
/**
|
|
1808
1831
|
* Configure HMR-specific options (port, host, path & protocol)
|
|
1809
1832
|
*/
|
|
@@ -2145,6 +2168,11 @@ export declare interface UserConfig {
|
|
|
2145
2168
|
* Preview specific options, e.g. host, port, https...
|
|
2146
2169
|
*/
|
|
2147
2170
|
preview?: PreviewOptions;
|
|
2171
|
+
/**
|
|
2172
|
+
* Force dep pre-optimization regardless of whether deps have changed.
|
|
2173
|
+
* @experimental
|
|
2174
|
+
*/
|
|
2175
|
+
force?: boolean;
|
|
2148
2176
|
/**
|
|
2149
2177
|
* Dep optimization options
|
|
2150
2178
|
*/
|
|
@@ -2297,7 +2325,6 @@ export declare interface ViteDevServer {
|
|
|
2297
2325
|
* @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
|
|
2298
2326
|
*/
|
|
2299
2327
|
restart(forceOptimize?: boolean): Promise<void>;
|
|
2300
|
-
/* Excluded from this release type: _optimizedDeps */
|
|
2301
2328
|
/* Excluded from this release type: _importGlobMap */
|
|
2302
2329
|
/* Excluded from this release type: _ssrExternals */
|
|
2303
2330
|
/* Excluded from this release type: _restartPromise */
|
package/dist/node/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
export { b as build,
|
|
1
|
+
export { b as build, j as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, i as isDepsOptimizerEnabled, l as loadConfigFromFile, q as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, p as preview, e as resolveConfig, u as resolveEnvPrefix, a as resolvePackageData, r as resolvePackageEntry, k as searchForWorkspaceRoot, h as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-0232e200.js';
|
|
2
2
|
import 'fs';
|
|
3
3
|
import 'path';
|
|
4
4
|
import 'url';
|
|
5
5
|
import 'perf_hooks';
|
|
6
6
|
import 'module';
|
|
7
7
|
import 'tty';
|
|
8
|
-
import 'os';
|
|
9
8
|
import 'esbuild';
|
|
10
9
|
import 'events';
|
|
11
10
|
import 'assert';
|
|
@@ -14,6 +13,7 @@ import 'util';
|
|
|
14
13
|
import 'net';
|
|
15
14
|
import 'http';
|
|
16
15
|
import 'stream';
|
|
16
|
+
import 'os';
|
|
17
17
|
import 'child_process';
|
|
18
18
|
import 'crypto';
|
|
19
19
|
import './constants.js';
|