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

Breaking change in recent version #32

Closed
lesha1201 opened this issue Apr 21, 2022 · 5 comments
Closed

Breaking change in recent version #32

lesha1201 opened this issue Apr 21, 2022 · 5 comments
Labels
question Further information is requested

Comments

@lesha1201
Copy link

lesha1201 commented Apr 21, 2022

Hello! I've recently tried to upgrade from version 1.1.1 to 1.1.7 and the build were failing with error Error: failed to handle: not implemented: automatic polyfill for scripts:

image

I noticed that isModule were changed to isModule: 'unknown' in this commit ed714ba. Changing it back to the default value isModule: true fixes it.

I don't know why it doesn't work with isModule: 'unknown' but letting you know about this issue and how it can be fixed if someone encounters it.

Info:

  • Storybook 6.4.19
  • React 17.0.2
  • TypeScript 4.6.2
  • @swc/core 1.2.170

Swc config:

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": true,
      "decorators": false,
      "dynamicImport": false
    },
    "loose": true
  },
  "env": {
    "targets": "> 0.5%, last 2 versions, Firefox ESR, not dead, not ie <= 11"
  }
}
@Karibash
Copy link
Owner

@lesha1201
Thank you for reporting the issue.

The relevant error seems to occur when going through the following process.
https://github.com/swc-project/swc/blob/747b8a188929b7f24b16f3b733d83909b424c948/crates/swc_ecma_preset_env/src/lib.rs#L447-L449

However, I don't have much knowledge of Rust, so I am not sure why this process is being executed.
It might be a problem on the SWC side, so it might be better to submit an issue in the SWC repository.

I will close this issue for now and re-open it if many others seem to encounter the same error.

@salamaashoush
Copy link

salamaashoush commented Apr 25, 2022

I have the same issue after upgrading from 1.1.5 to 1.1.7 if I downgrade it works fine, so I guess it might be something related to the addon not swc since I use latest swc in both cases, also after adding isModule:true it works fine with 1.1.7

@AleksandarDev
Copy link

AleksandarDev commented Jun 14, 2022

We are experiencing same issue with 1.1.7 addon, seems to work fine with latest swc and loader with 1.1.5 addon

Not working:

    "@swc/core": "1.2.203",
    "storybook-addon-swc": "1.1.7",
    "swc-loader": "0.2.3",

Working:

    "@swc/core": "1.2.203",
    "storybook-addon-swc": "1.1.5",
    "swc-loader": "0.2.3",

.swcrc:

{
  "env": {
    "targets": {
      "chrome": "90"
    }
  },
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": true
    },
    "target": "es2020"
  },
  "minify": true
}

@bes
Copy link

bes commented Aug 31, 2022

Same thing with 1.1.8, downgrading to 1.1.5 helps. I can add more information if needed @Karibash

EDIT: I fixed it by configuring isModule: true as suggested in the original post:

        {
            name: "storybook-addon-swc",
            options: {
                swcLoaderOptions: {
                    isModule: true, // This fixed my build
                    module: {
                        // Our storybook build needs commonjs, otherwise it won't compile properly.
                        // NOTE: Other GitHub users reading this might not need it.
                        type: "commonjs",
                    },
                },
            },
        },

@Karibash Karibash pinned this issue Aug 31, 2022
@Karibash
Copy link
Owner

The small number of people encountering the same problem makes me wonder if the swc settings of the person using it are simply incorrect.
I have pinned this issue so that others encountering the same glitch can find a solution.

By the way, the default value of isModule is false, not true.
https://swc.rs/docs/configuration/compilation#:~:text=false%0A%20%20%7D%2C-,%22isModule%22%3A%20false,-%7D

@Karibash Karibash added the question Further information is requested label Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants