Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@swc/plugin-transform-imports Removes side effect import on build #329

Closed
davNazaryan opened this issue Jul 5, 2024 · 0 comments · Fixed by #341
Closed

@swc/plugin-transform-imports Removes side effect import on build #329

davNazaryan opened this issue Jul 5, 2024 · 0 comments · Fixed by #341
Assignees

Comments

@davNazaryan
Copy link

Removes side-effect import on the build.

Input

import './upload/upload.ts';
import './scripts/scripts.model.js';

Expected build output

import './upload/upload.js';
import './scripts/scripts.model.js';

Actual output

import './scripts/scripts.model.js';

SWC config

...
"plugins": [
    [
        "@swc/plugin-transform-imports",
        {
            "^(.*?)(\\.ts)$": {
                "skipDefaultConversion": true,
                "transform": "{{matches.[1]}}.js"
            }
        }
    ]
]
...

Build script
pnpm swc source -d dist --strip-leading-paths --delete-dir-on-start --copy-files

I'm slowly moving my project from JS to TS, and this plugin provides excellent assistance in this process.
I tried to convert the upload.js to TS, but once I changed the file format, the build skipped it.
Once I remove this plugin from the SWC config, the file will appear as intended.

Sorry, I can't provide more information.

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

Successfully merging a pull request may close this issue.

2 participants