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

.swcrc is not used for JS minify() #7926

Closed
billykwok opened this issue Sep 7, 2023 · 4 comments · Fixed by #7936
Closed

.swcrc is not used for JS minify() #7926

billykwok opened this issue Sep 7, 2023 · 4 comments · Fixed by #7936
Assignees
Labels
Milestone

Comments

@billykwok
Copy link

billykwok commented Sep 7, 2023

Describe the bug

#7914 introduces an option to keep using assert instead with for backward compatibility. It works perfectly fine for transform, but the option is not respected when using minify even when the emitAssertForImportAttributes option is specified.

I'm actually not sure if this should be considered a bug since minify seemingly only takes the options under minify into account and ignores the rest of the config. But it would be great if there is a way to keep assert during minification, just like how transform behaves.

Unfortunately, I'm not familiar enough with Rust and swc to work on a PR. Maybe @kdy1 can look at this.

Config

{
  "jsc": {
    "target": "esnext",
    "parser": {
      "syntax": "typescript",
    },
    "experimental": {
      "keepImportAttributes": true,
      "emitAssertForImportAttributes": true
    }
  },
  "minify": true
}

Input code

No response

Config

No response

Playground link

https://play.swc.rs/?version=1.3.83&code=H4sIAAAAAAAAA8vMLcgvKlGoVkhUqFVIK8rPVVBPVFdILC5OBYuWVBakWimoZxXn56kr1FpzZcKUJ8GVJ6krlGeWZGBRzJVaATNcB6TBmgsAAsbJ7W4AAAA%3D&config=H4sIAAAAAAAAA42VzW7bMAyA732KwOcd2gEdht16KbDDnkFQLMphJ4uGSKcJirz7aMdO3YQOdrP58Ufinz4eNpvqjevq1%2BZDP%2FWn84WhXP5Vwscs%2FqCSSo4dcF2wk%2BrbTIUHJKWHUXI6g0p8aUAGI%2BDvj0%2FPk0GViBhUHH1imGQtZozHZcia2q4A80KmUnXZt5CFv9pPrNA7TydZyLdECXy%2BQ5xnh1mggWI5rikl3zG4vS%2BGl%2BGkviCTFWKAvUBwXaHO5DmgIGWNeUsD%2BOBqCmAgLFAL7sEy01hqllmvZ9xnxAG2fdOMZb6yhr1PvRcjJhzGkuhpDa87QhYX%2B2yl8AxXcnCGU3KvLTG6AtKXfGv3RphXavIXQDOQPHP2LVh%2BR42o%2FbRmHe9aYo7asnI0uPa3dcsMjSbVIUYjs0NmoAha1SwQ%2BhqGzNbWcSa8kj7GAA5i1F4xXPM7Sr2zgg5zTtEAWl8fra46A3eZwhU%2BDMQd%2FKq3FLvBJo3Wy26d8rHdUroToAXZUbijoKUQWsdFt8ShW%2Bd9DqCtAcFU6XkEt0tAB0DIpXFf3vSGjod6dE2i7eeamBROlzXc%2BtyM877Yl0Jdgj2ktTb%2BjxG5S%2FVs%2B6Gr58m%2BmV74aTWl18HDp8cZzVf58nxolqHgsOx9Wj4MQ9zfbUdFXkQKbnW7XrdpBS3KC%2BsjJq9UVpQf5pBjwKql0C%2ByNw7A%2Be36UX0qzc%2FUHK1C%2FjMbjk5P%2FwCn22zDTwcAAA%3D%3D

SWC Info output

No response

Expected behavior

import { a } from 'a' assert { type: 'json' };
import { b } from 'b' with { type: 'json' };

export { a, b };

transpiled and minified into

import{a as o}from"a"assert{type:"json"};import{b as t}from"b"with{type:"json"};export{o as a,t as b};

Actual behavior

import { a } from 'a' assert { type: 'json' };
import { b } from 'b' with { type: 'json' };

export { a, b };

transpiled and minified into

import{a as o}from"a"with{type:"json"};import{b as t}from"b"with{type:"json"};export{o as a,t as b};

Version

1.3.83

Additional context

No response

@billykwok billykwok added the C-bug label Sep 7, 2023
@isaacs
Copy link

isaacs commented Sep 7, 2023

This is a symptom of #7928

@billykwok billykwok changed the title SWC Minify does not respect "jsc.experimental.emitAssertForImportAttributes" SWC Minify does not respect emitAssertForImportAttributes Sep 8, 2023
@kdy1
Copy link
Member

kdy1 commented Sep 9, 2023

.swcrc is not used for .minify() and it's intended

@kdy1 kdy1 changed the title SWC Minify does not respect emitAssertForImportAttributes .swcrc is not used for JS minify() Sep 9, 2023
@kdy1 kdy1 added this to the Planned milestone Sep 11, 2023
@kdy1 kdy1 self-assigned this Sep 11, 2023
kdy1 added a commit that referenced this issue Sep 11, 2023
**Description:**

 - Add `format.emitAssertForImportAttributes` to `minify()`
 - Use `jsc.experimental. emitAssertForImportAttributes`.

**Related issue (if exists):**

 - Closes #7926
 - Closes #7928
@kdy1 kdy1 modified the milestones: Planned, v1.3.85 Sep 11, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 12, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

4 participants