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

Plugin conflict: [vite:css] plugins[i] is not a function #8410

Closed
7 tasks done
theprojectsomething opened this issue May 31, 2022 · 1 comment · Fixed by #8415
Closed
7 tasks done

Plugin conflict: [vite:css] plugins[i] is not a function #8410

theprojectsomething opened this issue May 31, 2022 · 1 comment · Fixed by #8415
Labels
p2-edge-case Bug, but has workaround or limited in scope (priority)

Comments

@theprojectsomething
Copy link

theprojectsomething commented May 31, 2022

Describe the bug

I'm attempting to allow import assertions in a vite build using the acorn plugin acorn-import-assertions e.g:

// vite.config.js
import { defineConfig } from 'vite'
import { importAssertions } from 'acorn-import-assertions';

export default defineConfig({
  build: {
    rollupOptions: {
      // note the plugin isn't instantiated here
      acornInjectPlugins: [ importAssertions ],
    },
  },
})
// entry.js
import data from 'data.json' assert { type: 'json' }

On build vite throws an error: [vite:css] plugins[i] is not a function that tracks back to a function (Parser.extend) in one of the node chunks in the dist folder. If I patch that file (to check for a function type before attempting to execute it) everything works as expected.

Assuming this is a conflict with PostCSS or similar due to the extra baggage on the end of the import syntax, but not sure where to begin looking as I couldn't find any reference in source.

Any help much appreciated!

Reproduction

Minimal reproduction => npm run dev

System Info

System:
    OS: macOS 12.4
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Memory: 1.15 GB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 15.2.0 - ~/.nvm/versions/node/v15.2.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.0.8 - ~/.nvm/versions/node/v15.2.0/bin/npm
  Browsers:
    Chrome: 101.0.4951.64
    Edge: 101.0.1210.53
    Firefox Developer Edition: 101.0
    Safari: 15.5
  npmPackages:
    vite: ^2.9.9 => 2.9.9

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red
Copy link
Member

For a workaround, change it to non array like this.

acornInjectPlugins: importAssertions,

@sapphi-red sapphi-red added p2-edge-case Bug, but has workaround or limited in scope (priority) and removed pending triage labels May 31, 2022
sapphi-red added a commit to sapphi-red/vite that referenced this issue May 31, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p2-edge-case Bug, but has workaround or limited in scope (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants