Skip to content

[Bug] Error: env and jsc.target cannot be used together #17

Open
@harsharavindra

Description

@harsharavindra

Describe the bug

I am getting this error when "npm run storybook"

I am suspecting this error is from this package.

Steps to reproduce the behavior

My main.js:

module.exports = {
  stories: ['../packages/**/index.stories.tsx', '../packages/autocomplete/src/index.stories.js', '../packages/table/src/stories/**.tsx', '../packages/icons/src/index.stories.js'],
  addons: [
    '@storybook/addon-essentials',
    '@storybook/addon-storysource',
    '@storybook/addon-a11y',
    '@storybook/addon-backgrounds',
    '@storybook/addon-links',
    '@storybook/addon-webpack5-compiler-swc',
    '@chromatic-com/storybook'
  ],
  framework: {
    name: '@storybook/react-webpack5',
    options: {
      fsCache: true,
      lazyCompilation: true
    }
  },
  core: {
    builder: 'webpack5'
  }
};

and my .swcrc file which is used to build my packages:

{
  "$schema": "http://json.schemastore.org/swcrc",
  "module": {
    "type": "es6"
  },
  
  "jsc": {
    "target": "es2018",

    "parser": {
      "syntax": "typescript",
      "tsx": true,
      "decorators": false,
      "dynamicImport": false
    },

    "transform": {
      "react": {
        "runtime": "automatic"
      }
    }
  },
  "sourceMaps": true,
  "exclude": [".*\\.test\\.tsx?$", ".*\\.playroom\\.ts$"]
}

Removing "target": "es2018", and adding env works, but I want to keep "target": "es2018".

is the error due to :

https://github.com/storybookjs/addon-webpack5-compiler-swc/blob/main/src/preset.ts#L13

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions