Currently, it appears the transform-imports plugin only supports named imports and exports. Namespace and default imports/exports are completely ignored.
By extension, mixed imports (import foo, { bar } from "module-name" or import foo, * as bar from "module-name") are also left untouched.
This is a problem when using the plugin:
to rename an import module name partially or completely
to rewrite/append an extension to the module name (e.g. in relative imports)
Currently, the following examples:
// Works - outputs `import { someFunction } from "./somefile.mjs"`
import { someFunction } from "./somefile.ts";
// Works - outputs `import { someOtherFunction as someOtherFn } from "./somefile.mjs"`
import { someOtherFunction as someOtherFn } from "./somefile.ts";
// Works - outputs `export * from ./somefile.mjs`
export * from "./somefile.ts";
// Works - outputs `export {someFunction} from "./somefile.mjs"`
export { someFunction } from "./somefile.ts";
are transformed as expected, while
// Does not work - outputs `import defaultFunction from "./somefile.ts"`
import defaultFunction from "./somefile.ts";
// Does not work - outputs `import defaultFunction, { someFunction, someOtherFunction as someOtherFn } from "./somefile.ts"`
import defaultFunction, { someFunction, someOtherFunction as someOtherFn } from "./somefile.ts";
// Does not work - outputs `import defaultFunction, * as someModule from "./somefile.ts"`
import defaultFunction, * as someModule from "./somefile.ts";
// Does not work - outputs `export * as someModule from "./somefile.ts"`
export * as someModule from "./somefile.ts";
are not touched by the plugin.
This can be verified using @swc/plugin-transform-imports@2.0.7 (@swc/core@1.6.6), with the following .swcrc config:
Currently, it appears the
transform-imports
plugin only supports named imports and exports. Namespace and default imports/exports are completely ignored. By extension, mixed imports (import foo, { bar } from "module-name"
orimport foo, * as bar from "module-name"
) are also left untouched.This is a problem when using the plugin:
Currently, the following examples:
are transformed as expected, while
are not touched by the plugin.
This can be verified using
@swc/plugin-transform-imports@2.0.7
(@swc/core@1.6.6
), with the following.swcrc
config:Minimum reproduction example: https://github.com/dp-152/swc-plugin-transform-imports-repro