@saqu/transform-plugin-import-replace-alias
TypeScript icon, indicating that this package has built-in type declarations

0.1.40 • Public • Published

@saqu/transform-plugin-import-replace-alias

替换引入包名称

import { parseSync } from '@swc/core'

const code = `
import React from 'react';
import * as allReact from 'test-doc';
const Demo = ()=>{
  return <div>222</div>
}
export default Demo;
`;

const m = parseSync(code,{ "syntax": "typescript", "tsx": true, "decorators": true})

new transformPluginAlias({ alias: [{ libraryName: 'test-doc', alias: 'react' }]}).visitProgram(m)

Readme

Keywords

none

Package Sidebar

Install

npm i @saqu/transform-plugin-import-replace-alias

Weekly Downloads

15

Version

0.1.40

License

ISC

Unpacked Size

3.59 kB

Total Files

6

Last publish

Collaborators

  • sunluxy