A custom transformer that can be used with ttypescript to transform ts imports to browser style imports
Home > config > RewriteRulesURL
Rewrite module to another URL
Signature:
export interface RewriteRulesURL
{
"type": "url",
"withVersion": "https://cdn.example.com/$packageName$/v$version$""
"noVersion": "https://cdn.example.com/$packageName$/latest"
}
Source code:
Filename: rules-default.ts
console.log('Should run after all imports', a, b, c2, d, e, c2)
// Node style import
import a from 'a'
import b, { c as c2, d } from 'b'
import * as e from 'c'
import 'd'
const c = 1
const x = 1
export { x }
// Node style export
export { c, d } from 'b'
export * as e from 'c'
Output:
Filename: rules-url.js
// CompilerOptions: {"module":"ESNext"}
// PluginConfig: {"rules":{"type":"url","withVersion":"std:$packageName$@$version$","noVersion":"std:$packageName$"}}
console.log('Should run after all imports', a, b, c2, d, e, c2);
// Node style import
import a from "std:a";
import b, { c as c2, d } from "std:b";
import * as e from "std:c";
import "std:d";
const c = 1;
const x = 1;
export { x };
// Node style export
export { c, d } from "std:b";
export * as e from "std:c";
Property | Type | Description |
---|---|---|
noVersion | string | Rewrite to this URL if the transformer can’t read the version of the package |
type | ‘url’ | |
withVersion | string | Rewrite to this URL if the transformer can read the version of the package |