WarrenJones / vite-plugin-require-transform

A plugin for vite that convert from require syntax to import
82 stars 14 forks source link

SyntaxError: Cannot use import statement outside a module #34

Closed Dank-del closed 1 year ago

Dank-del commented 1 year ago
Screenshot 2023-01-22 at 8 49 04 PM

My package.json

{
  "name": "watch-cf",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "@consumet/extensions": "^1.3.0",
    "@silvermine/videojs-quality-selector": "^1.2.5",
    "react": "^17.0.2",
    "react-cookie": "^4.1.1",
    "react-dom": "^17.0.2",
    "react-helmet": "^6.1.0",
    "react-router-dom": "^6.6.1",
    "react-toastify": "^9.1.1",
    "string-strip-html": "^13.0.6",
    "swiper": "^8.4.5",
    "swr": "^2.0.0",
    "video.js": "^7.20.3",
    "vite": "^3.2.5"
  },
  "devDependencies": {
    "@vitejs/plugin-react": "^1.0.7",
    "autoprefixer": "^10.4.2",
    "daisyui": "^2.6.0",
    "postcss": "^8.4.7",
    "tailwindcss": "^3.0.23",
    "vite-plugin-require-transform": "^1.0.6"
  }
}
ryanlntn commented 1 year ago

This seem to be related to this change. Reverting to 1.0.4 worked for me.

WarrenJones commented 1 year ago
Screenshot 2023-01-22 at 8 49 04 PM

My package.json

{
  "name": "watch-cf",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "@consumet/extensions": "^1.3.0",
    "@silvermine/videojs-quality-selector": "^1.2.5",
    "react": "^17.0.2",
    "react-cookie": "^4.1.1",
    "react-dom": "^17.0.2",
    "react-helmet": "^6.1.0",
    "react-router-dom": "^6.6.1",
    "react-toastify": "^9.1.1",
    "string-strip-html": "^13.0.6",
    "swiper": "^8.4.5",
    "swr": "^2.0.0",
    "video.js": "^7.20.3",
    "vite": "^3.2.5"
  },
  "devDependencies": {
    "@vitejs/plugin-react": "^1.0.7",
    "autoprefixer": "^10.4.2",
    "daisyui": "^2.6.0",
    "postcss": "^8.4.7",
    "tailwindcss": "^3.0.23",
    "vite-plugin-require-transform": "^1.0.6"
  }
}

Thanks for reporting,it's been fixed in version 1.0.8,you can check it out.Actually now I'm still not familiar with commonjs and esm but there will be a perfect landing not far in the future.