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

Can't build when use primevue #374

Open
5 tasks done
fernanduandrade opened this issue Sep 28, 2023 · 5 comments
Open
5 tasks done

Can't build when use primevue #374

fernanduandrade opened this issue Sep 28, 2023 · 5 comments

Comments

@fernanduandrade
Copy link

fernanduandrade commented Sep 28, 2023

Describe the bug

Hello guys, I'm currently facing a problem where I installed primevue for my project and I'm unable to create the build when I run vite-ssg build it gives the following error bellow. Unfortunately I didn't find a similiar problem searching in forums and I also tried adding in my vite.config.ts in the ssrOptions the esm formart, but it didn't work.
Does anyone has any ideia how could I solve this?
Screenshot from 2023-09-28 07-39-44

Reproduction

Add primevue in the vite project, when run the build with vite-ssg it thorws the error

System Info

node:7166) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)

[vite-ssg] An internal error occurred.
[vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues
/home/fernando/Desktop/my-project/node_modules/primevue/config/config.esm.js:1
import { FilterMatchMode } from 'primevue/api';
^^^^^^

SyntaxError: Cannot use import statement outside a module

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@anthopit
Copy link

anthopit commented Nov 6, 2023

Same error! Have you found a solution?

@fernanduandrade
Copy link
Author

Same error! Have you found a solution?

no solution yet, still searching

@userquin
Copy link
Member

userquin commented Nov 6, 2023

try adding these aliases:

// vite.config.ts/vite.config.js
  resolve: {
    alias: {
      'primevue/config': 'primevue/config/config.cjs.js',
      'primevue/api': 'primevue/api/api.cjs.js',
    }
  },

@fernanduandrade
Copy link
Author

try adding these aliases:

// vite.config.ts/vite.config.js
  resolve: {
    alias: {
      'primevue/config': 'primevue/config/config.cjs.js',
      'primevue/api': 'primevue/api/api.cjs.js',
    }
  },

almost worked, but im facing a different problems now with the icons

@ctd1500
Copy link

ctd1500 commented Jan 29, 2024

This is the workaround I figured out for a working vite.config

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import resolve from "@rollup/plugin-node-resolve";

const customResolver = resolve({
    extensions: [".esm.js", ".css", ".scss"]
});

export default defineConfig({
  plugins: [
    vue(),
  ],
  ssgOptions: {
    script: "async",
    formatting: "prettify",
  },
  resolve: {
    alias: [
      {
        find: "primevue",
        customResolver: customResolver,
        replacement: function(alias) {
          return alias;
        }
      }
    ]
  },
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants