Skip to content

refactor(language-core): pluginized source map factory function#207

Merged
johnsoncodehk merged 1 commit intomasterfrom
mapper-factory
Jun 22, 2024
Merged

refactor(language-core): pluginized source map factory function#207
johnsoncodehk merged 1 commit intomasterfrom
mapper-factory

Conversation

@johnsoncodehk
Copy link
Member

@johnsoncodehk johnsoncodehk commented Jun 21, 2024

Closes #203

Define the factory function of the source map through Language.mapperFactory, which allows the insertion of customized mapping logic.

Motivation

Individual frameworks may require somewhat special mapping processing logic. For example, WebStorm-Angular requires special processing for overlapping mapping ranges. These processing may not be common to all frameworks, so it is best to make the mapping behavior itself customizable.

Usage

After creating the Language instance, set mapperFactory property to override the default SourceMap factory function.

createLanguageServicePlugin((ts, info) => ({
	languagePlugins: [/* ... */],
	setup(language) {
		language.mapperFactory = mappings => new MySourceMap(mappings);
	},
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support overlapping mapping ranges

1 participant