Skip to content

Commit 4f8708a

Browse files
authored
chore: use pkg.imports for builder.js (#15785)
* chore: use pkg.imports for builder.js * use pkg.imports instead of tsconfig * #client/constants
1 parent 262b281 commit 4f8708a

File tree

111 files changed

+127
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+127
-113
lines changed

packages/svelte/package.json

+11
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@
103103
"default": "./src/events/index.js"
104104
}
105105
},
106+
"imports": {
107+
"#client": "./src/internal/client/types.d.ts",
108+
"#client/constants": "./src/internal/client/constants.js",
109+
"#compiler": {
110+
"types": "./src/compiler/private.d.ts",
111+
"default": "./src/compiler/index.js"
112+
},
113+
"#compiler/builders": "./src/compiler/utils/builders.js",
114+
"#server": "./src/internal/server/types.d.ts",
115+
"#shared": "./src/internal/shared/types.d.ts"
116+
},
106117
"repository": {
107118
"type": "git",
108119
"url": "git+https://github.com./sveltejs/svelte.git",

packages/svelte/scripts/generate-types.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ await createBundle({
2424
output: `${dir}/types/index.d.ts`,
2525
compilerOptions: {
2626
// so that types/properties with `@internal` (and its dependencies) are removed from the output
27-
stripInternal: true
27+
stripInternal: true,
28+
paths: Object.fromEntries(
29+
Object.entries(pkg.imports).map(([key, value]) => {
30+
return [key, [value.types ?? value.default ?? value]];
31+
})
32+
)
2833
},
2934
modules: {
3035
[pkg.name]: `${dir}/src/index.d.ts`,

packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { Context, Visitors } from 'zimmerframe' */
22
/** @import { FunctionExpression, FunctionDeclaration } from 'estree' */
33
import { walk } from 'zimmerframe';
4-
import * as b from '../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55
import * as e from '../../errors.js';
66

77
/**

packages/svelte/src/compiler/phases/2-analyze/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { walk } from 'zimmerframe';
66
import * as e from '../../errors.js';
77
import * as w from '../../warnings.js';
88
import { extract_identifiers } from '../../utils/ast.js';
9-
import * as b from '../../utils/builders.js';
9+
import * as b from '#compiler/builders';
1010
import { Scope, ScopeRoot, create_scopes, get_rune, set_scope } from '../scope.js';
1111
import check_graph_for_cycles from './utils/check_graph_for_cycles.js';
1212
import { create_attribute, is_custom_element_node } from '../nodes.js';

packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as e from '../../../errors.js';
66
import { get_parent } from '../../../utils/ast.js';
77
import { is_pure, is_safe_identifier } from './shared/utils.js';
88
import { dev, locate_node, source } from '../../../state.js';
9-
import * as b from '../../../utils/builders.js';
9+
import * as b from '#compiler/builders';
1010

1111
/**
1212
* @param {CallExpression} node

packages/svelte/src/compiler/phases/2-analyze/visitors/shared/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import * as e from '../../../../errors.js';
77
import { extract_identifiers } from '../../../../utils/ast.js';
88
import * as w from '../../../../warnings.js';
9-
import * as b from '../../../../utils/builders.js';
9+
import * as b from '#compiler/builders';
1010
import { get_rune } from '../../../scope.js';
1111

1212
/**

packages/svelte/src/compiler/phases/3-transform/client/transform-client.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/** @import { ComponentAnalysis, Analysis } from '../../types' */
44
/** @import { Visitors, ComponentClientTransformState, ClientTransformState } from './types' */
55
import { walk } from 'zimmerframe';
6-
import * as b from '../../../utils/builders.js';
6+
import * as b from '#compiler/builders';
77
import { build_getter, is_state_source } from './utils.js';
88
import { render_stylesheet } from '../css/index.js';
99
import { dev, filename } from '../../../state.js';

packages/svelte/src/compiler/phases/3-transform/client/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/** @import { ClientTransformState, ComponentClientTransformState, ComponentContext } from './types.js' */
44
/** @import { Analysis } from '../../types.js' */
55
/** @import { Scope } from '../../scope.js' */
6-
import * as b from '../../../utils/builders.js';
6+
import * as b from '#compiler/builders';
77
import { is_simple_expression } from '../../../utils/ast.js';
88
import {
99
PROPS_IS_LAZY_INITIAL,

packages/svelte/src/compiler/phases/3-transform/client/visitors/AnimateDirective.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { Expression } from 'estree' */
22
/** @import { AST } from '#compiler' */
33
/** @import { ComponentContext } from '../types' */
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55
import { parse_directive_name } from './shared/utils.js';
66

77
/**

packages/svelte/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { AssignmentExpression, AssignmentOperator, Expression, Identifier, Pattern } from 'estree' */
22
/** @import { AST } from '#compiler' */
33
/** @import { Context } from '../types.js' */
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55
import {
66
build_assignment_value,
77
get_attribute_expression,

packages/svelte/src/compiler/phases/3-transform/client/visitors/AwaitBlock.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/** @import { AST } from '#compiler' */
33
/** @import { ComponentClientTransformState, ComponentContext } from '../types' */
44
import { extract_identifiers } from '../../../../utils/ast.js';
5-
import * as b from '../../../../utils/builders.js';
5+
import * as b from '#compiler/builders';
66
import { create_derived } from '../utils.js';
77
import { get_value } from './shared/declarations.js';
88

packages/svelte/src/compiler/phases/3-transform/client/visitors/BinaryExpression.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { Expression, BinaryExpression } from 'estree' */
22
/** @import { ComponentContext } from '../types' */
33
import { dev } from '../../../../state.js';
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55

66
/**
77
* @param {BinaryExpression} node

packages/svelte/src/compiler/phases/3-transform/client/visitors/BindDirective.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/** @import { ComponentContext } from '../types' */
44
import { dev, is_ignored } from '../../../../state.js';
55
import { is_text_attribute } from '../../../../utils/ast.js';
6-
import * as b from '../../../../utils/builders.js';
6+
import * as b from '#compiler/builders';
77
import { binding_properties } from '../../../bindings.js';
88
import { build_attribute_value } from './shared/element.js';
99
import { build_bind_this, validate_binding } from './shared/utils.js';

packages/svelte/src/compiler/phases/3-transform/client/visitors/BlockStatement.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { ArrowFunctionExpression, BlockStatement, Expression, FunctionDeclaration, FunctionExpression, Statement } from 'estree' */
22
/** @import { ComponentContext } from '../types' */
33
import { add_state_transformers } from './shared/declarations.js';
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55

66
/**
77
* @param {BlockStatement} node

packages/svelte/src/compiler/phases/3-transform/client/visitors/BreakStatement.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @import { BreakStatement } from 'estree' */
22
/** @import { ComponentContext } from '../types' */
3-
import * as b from '../../../../utils/builders.js';
3+
import * as b from '#compiler/builders';
44

55
/**
66
* @param {BreakStatement} node

packages/svelte/src/compiler/phases/3-transform/client/visitors/CallExpression.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { CallExpression, Expression } from 'estree' */
22
/** @import { Context } from '../types' */
33
import { dev, is_ignored } from '../../../../state.js';
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55
import { get_rune } from '../../../scope.js';
66
import { transform_inspect_rune } from '../../utils.js';
77

packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @import { ClassBody, Expression, Identifier, Literal, MethodDefinition, PrivateIdentifier, PropertyDefinition } from 'estree' */
22
/** @import { Context, StateField } from '../types' */
3-
import * as b from '../../../../utils/builders.js';
3+
import * as b from '#compiler/builders';
44
import { regex_invalid_identifier_chars } from '../../../patterns.js';
55
import { get_rune } from '../../../scope.js';
66
import { should_proxy } from '../utils.js';

packages/svelte/src/compiler/phases/3-transform/client/visitors/Component.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { Expression } from 'estree' */
22
/** @import { AST } from '#compiler' */
33
/** @import { ComponentContext } from '../types' */
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55
import { build_component } from './shared/component.js';
66

77
/**

packages/svelte/src/compiler/phases/3-transform/client/visitors/ConstTag.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/** @import { ComponentContext } from '../types' */
44
import { dev } from '../../../../state.js';
55
import { extract_identifiers } from '../../../../utils/ast.js';
6-
import * as b from '../../../../utils/builders.js';
6+
import * as b from '#compiler/builders';
77
import { create_derived } from '../utils.js';
88
import { get_value } from './shared/declarations.js';
99

packages/svelte/src/compiler/phases/3-transform/client/visitors/DebugTag.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { Expression} from 'estree' */
22
/** @import { AST } from '#compiler' */
33
/** @import { ComponentContext } from '../types' */
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55

66
/**
77
* @param {AST.DebugTag} node

packages/svelte/src/compiler/phases/3-transform/client/visitors/EachBlock.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '../../../../../constants.js';
1212
import { dev } from '../../../../state.js';
1313
import { extract_paths, object } from '../../../../utils/ast.js';
14-
import * as b from '../../../../utils/builders.js';
14+
import * as b from '#compiler/builders';
1515
import { build_getter } from '../utils.js';
1616
import { get_value } from './shared/declarations.js';
1717

packages/svelte/src/compiler/phases/3-transform/client/visitors/ExportNamedDeclaration.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @import { ExportNamedDeclaration } from 'estree' */
22
/** @import { ComponentContext } from '../types' */
3-
import * as b from '../../../../utils/builders.js';
3+
import * as b from '#compiler/builders';
44

55
/**
66
* @param {ExportNamedDeclaration} node

packages/svelte/src/compiler/phases/3-transform/client/visitors/ExpressionStatement.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @import { Expression, ExpressionStatement } from 'estree' */
22
/** @import { ComponentContext } from '../types' */
3-
import * as b from '../../../../utils/builders.js';
3+
import * as b from '#compiler/builders';
44
import { get_rune } from '../../../scope.js';
55

66
/**

packages/svelte/src/compiler/phases/3-transform/client/visitors/Fragment.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/** @import { ComponentClientTransformState, ComponentContext } from '../types' */
55
import { TEMPLATE_FRAGMENT, TEMPLATE_USE_IMPORT_NODE } from '../../../../../constants.js';
66
import { dev } from '../../../../state.js';
7-
import * as b from '../../../../utils/builders.js';
7+
import * as b from '#compiler/builders';
88
import { sanitize_template_string } from '../../../../utils/sanitize_template_string.js';
99
import { clean_nodes, infer_namespace } from '../../utils.js';
1010
import { process_children } from './shared/fragment.js';

packages/svelte/src/compiler/phases/3-transform/client/visitors/FunctionDeclaration.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { FunctionDeclaration } from 'estree' */
22
/** @import { ComponentContext } from '../types' */
33
import { build_hoisted_params } from '../utils.js';
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55

66
/**
77
* @param {FunctionDeclaration} node

packages/svelte/src/compiler/phases/3-transform/client/visitors/HtmlTag.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/** @import { AST } from '#compiler' */
33
/** @import { ComponentContext } from '../types' */
44
import { is_ignored } from '../../../../state.js';
5-
import * as b from '../../../../utils/builders.js';
5+
import * as b from '#compiler/builders';
66

77
/**
88
* @param {AST.HtmlTag} node

packages/svelte/src/compiler/phases/3-transform/client/visitors/Identifier.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { Identifier, Node } from 'estree' */
22
/** @import { Context } from '../types' */
33
import is_reference from 'is-reference';
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55
import { build_getter } from '../utils.js';
66

77
/**

packages/svelte/src/compiler/phases/3-transform/client/visitors/IfBlock.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { BlockStatement, Expression } from 'estree' */
22
/** @import { AST } from '#compiler' */
33
/** @import { ComponentContext } from '../types' */
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55

66
/**
77
* @param {AST.IfBlock} node

packages/svelte/src/compiler/phases/3-transform/client/visitors/ImportDeclaration.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @import { ImportDeclaration } from 'estree' */
22
/** @import { ComponentContext } from '../types' */
3-
import * as b from '../../../../utils/builders.js';
3+
import * as b from '#compiler/builders';
44

55
/**
66
* @param {ImportDeclaration} node

packages/svelte/src/compiler/phases/3-transform/client/visitors/KeyBlock.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { Expression } from 'estree' */
22
/** @import { AST } from '#compiler' */
33
/** @import { ComponentContext } from '../types' */
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55

66
/**
77
* @param {AST.KeyBlock} node

packages/svelte/src/compiler/phases/3-transform/client/visitors/LabeledStatement.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { Expression, LabeledStatement, Statement } from 'estree' */
22
/** @import { ReactiveStatement } from '#compiler' */
33
/** @import { ComponentContext } from '../types' */
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55
import { build_getter } from '../utils.js';
66

77
/**

packages/svelte/src/compiler/phases/3-transform/client/visitors/LetDirective.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { Expression } from 'estree' */
22
/** @import { AST } from '#compiler' */
33
/** @import { ComponentContext } from '../types' */
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55
import { create_derived } from '../utils.js';
66

77
/**

packages/svelte/src/compiler/phases/3-transform/client/visitors/MemberExpression.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @import { MemberExpression } from 'estree' */
22
/** @import { Context } from '../types' */
3-
import * as b from '../../../../utils/builders.js';
3+
import * as b from '#compiler/builders';
44

55
/**
66
* @param {MemberExpression} node

packages/svelte/src/compiler/phases/3-transform/client/visitors/OnDirective.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @import { AST } from '#compiler' */
22
/** @import { ComponentContext } from '../types' */
3-
import * as b from '../../../../utils/builders.js';
3+
import * as b from '#compiler/builders';
44
import { build_event, build_event_handler } from './shared/events.js';
55

66
const modifiers = [

packages/svelte/src/compiler/phases/3-transform/client/visitors/Program.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { Expression, ImportDeclaration, MemberExpression, Program } from 'estree' */
22
/** @import { ComponentContext } from '../types' */
33
import { build_getter, is_prop_source } from '../utils.js';
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55
import { add_state_transformers } from './shared/declarations.js';
66

77
/**

packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { escape_html } from '../../../../../escaping.js';
1414
import { dev, is_ignored, locator } from '../../../../state.js';
1515
import { is_event_attribute, is_text_attribute } from '../../../../utils/ast.js';
16-
import * as b from '../../../../utils/builders.js';
16+
import * as b from '#compiler/builders';
1717
import { is_custom_element_node } from '../../../nodes.js';
1818
import { clean_nodes, determine_namespace_for_children } from '../../utils.js';
1919
import { build_getter } from '../utils.js';

packages/svelte/src/compiler/phases/3-transform/client/visitors/RenderTag.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/** @import { AST } from '#compiler' */
33
/** @import { ComponentContext } from '../types' */
44
import { unwrap_optional } from '../../../../utils/ast.js';
5-
import * as b from '../../../../utils/builders.js';
5+
import * as b from '#compiler/builders';
66

77
/**
88
* @param {AST.RenderTag} node

packages/svelte/src/compiler/phases/3-transform/client/visitors/SlotElement.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { BlockStatement, Expression, ExpressionStatement, Literal, Property } from 'estree' */
22
/** @import { AST } from '#compiler' */
33
/** @import { ComponentContext } from '../types' */
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55
import { build_attribute_value } from './shared/element.js';
66
import { memoize_expression } from './shared/utils.js';
77

packages/svelte/src/compiler/phases/3-transform/client/visitors/SnippetBlock.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/** @import { ComponentContext } from '../types' */
44
import { dev } from '../../../../state.js';
55
import { extract_paths } from '../../../../utils/ast.js';
6-
import * as b from '../../../../utils/builders.js';
6+
import * as b from '#compiler/builders';
77
import { get_value } from './shared/declarations.js';
88

99
/**

packages/svelte/src/compiler/phases/3-transform/client/visitors/SvelteBoundary.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/** @import { AST } from '#compiler' */
33
/** @import { ComponentContext } from '../types' */
44
import { dev } from '../../../../state.js';
5-
import * as b from '../../../../utils/builders.js';
5+
import * as b from '#compiler/builders';
66

77
/**
88
* @param {AST.SvelteBoundary} node

packages/svelte/src/compiler/phases/3-transform/client/visitors/SvelteElement.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/** @import { ComponentContext } from '../types' */
44
import { dev, locator } from '../../../../state.js';
55
import { is_text_attribute } from '../../../../utils/ast.js';
6-
import * as b from '../../../../utils/builders.js';
6+
import * as b from '#compiler/builders';
77
import { determine_namespace_for_children } from '../../utils.js';
88
import { build_attribute_value, build_set_attributes, build_set_class } from './shared/element.js';
99
import { build_render_statement } from './shared/utils.js';

packages/svelte/src/compiler/phases/3-transform/client/visitors/SvelteHead.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { BlockStatement } from 'estree' */
22
/** @import { AST } from '#compiler' */
33
/** @import { ComponentContext } from '../types' */
4-
import * as b from '../../../../utils/builders.js';
4+
import * as b from '#compiler/builders';
55

66
/**
77
* @param {AST.SvelteHead} node

packages/svelte/src/compiler/phases/3-transform/client/visitors/TitleElement.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @import { AST } from '#compiler' */
22
/** @import { ComponentContext } from '../types' */
3-
import * as b from '../../../../utils/builders.js';
3+
import * as b from '#compiler/builders';
44
import { build_template_chunk } from './shared/utils.js';
55

66
/**

0 commit comments

Comments
 (0)