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

@babel/plugin-transform-parameters not working correctly #519

Open
dithom opened this issue Aug 24, 2021 · 2 comments
Open

@babel/plugin-transform-parameters not working correctly #519

dithom opened this issue Aug 24, 2021 · 2 comments
Labels
question Further information is requested

Comments

@dithom
Copy link

dithom commented Aug 24, 2021

Describe the bug
When using babel in conjunction with nuxt typescript I run into an issue using @nuxt/babel-preset-env, which contains @babel/plugin-transform-parameters. Default parameters should be transpiled for compatibility with e.g. IE11 but in the resulting bundles they are still present:

... t.enc.Base64url={stringify:function(t,e=!0){ ... }} ... <= e=!0

and

... return o.join("")},parse:function(t,e=!0){ ... } ... <= e=!0

Edit: I could track the issue down to crypto-js beeing the source of the functions causing the problems.

To Reproduce
My config is:

nuxt.config.js

build: {
  babel: {
    presets: [
      [
        '@nuxt/babel-preset-app',
        {
          ignoreBrowserslistConfig: true,
        },
      ],
    ],
  },
},

tsconfig.json

{
  "compilerOptions": {
    "target": "ES2018",
    "module": "ESNext",
    "moduleResolution": "Node",
    "lib": [
      "ESNext",
      "ESNext.AsyncIterable",
      "DOM"
    ],
    "esModuleInterop": true,
    "allowJs": true,
    "sourceMap": true,
    "strict": true,
    "noEmit": true,
    "experimentalDecorators": true,
    "baseUrl": ".",
    "paths": {
      "~/*": [
        "./*"
      ],
      "@/*": [
        "./*"
      ]
    },
    "types": [
      "@nuxt/types",
      "@types/node",
      "@nuxtjs/axios"
    ]
  },
  "exclude": [
    "node_modules",
    ".nuxt",
    "dist"
  ]
}

Expected behavior
Default parameters should be transpiled correctly

... t.enc.Base64url={stringify:function(t,e){ ... }} ...

Additional context
I could not track down the source of these functions yet, but I'm using:

  • crypto-js
  • js-cookie
  • swiper
  • vue-awesome-swiper
  • vuex-module-decorators
@nathanhae
Copy link

@dithom did you ever figure this out?

@rchl
Copy link
Collaborator

rchl commented May 18, 2023

Doesn't sound like something specific to this module. Nuxt by default doesn't transpile dependencies from node_modules so if you want to transpile crypto-js, for example, you have to manually tell Nuxt to do it with something like this in Nuxt config:

    build: {
        transpile: [
            '/crypto-js/',
        ],
    },

@rchl rchl added the question Further information is requested label May 18, 2023
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

3 participants