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

ESM support #10

Closed
Heartnett opened this issue Aug 31, 2021 · 3 comments
Closed

ESM support #10

Heartnett opened this issue Aug 31, 2021 · 3 comments

Comments

@Heartnett
Copy link

I'm currently getting this error when building my ESM project:

failed to load config from ......./vite.config.ts
error when starting dev server:
ReferenceError: __dirname is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '......./package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///......./node_modules/.pnpm/[email protected][email protected]/node_modules/unplugin/dist/index.mjs:226:40
at ModuleJob.run (internal/modules/esm/module_job.js:170:25)
at async Loader.import (internal/modules/esm/loader.js:178:24)
at async loadConfigFromFile (.......\node_modules.pnpm\[email protected]\node_modules\vite\dist\node\chunks\dep-972722fa.js:75819:31)
at async resolveConfig (.......\node_modules.pnpm\[email protected]\node_modules\vite\dist\node\chunks\dep-972722fa.js:75434:28)
at async createServer (.......\node_modules.pnpm\[email protected]\node_modules\vite\dist\node\chunks\dep-972722fa.js:73957:20)
at async CAC. (.......\node_modules.pnpm\[email protected]\node_modules\vite\dist\node\cli.js:13963:24)

@antfu antfu closed this as completed in 2a5da06 Aug 31, 2021
@Heartnett
Copy link
Author

@antfu Thank you so much for the quick fix!

Unfortunately I'm now facing a new error:

failed to load config from .....\vite.config.ts
error when starting dev server:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of URL. Received undefined
at fileURLToPath (internal/url.js:1379:11)
at file:///...../node_modules/.pnpm/[email protected][email protected]/node_modules/unplugin/dist/index.mjs:228:79
at ModuleJob.run (internal/modules/esm/module_job.js:170:25)
at async Loader.import (internal/modules/esm/loader.js:178:24)
at async loadConfigFromFile (.....\node_modules.pnpm\[email protected]\node_modules\vite\dist\node\chunks\dep-972722fa.js:75819:31)
at async resolveConfig (.....\node_modules.pnpm\[email protected]\node_modules\vite\dist\node\chunks\dep-972722fa.js:75434:28)
at async createServer (.....\node_modules.pnpm\[email protected]\node_modules\vite\dist\node\chunks\dep-972722fa.js:73957:20)
at async CAC. (.....\node_modules.pnpm\[email protected]\node_modules\vite\dist\node\cli.js:13963:24)
 ERROR  Command failed with exit code 1.

@antfu antfu reopened this Aug 31, 2021
@antfu antfu closed this as completed in 4450e1e Aug 31, 2021
@Heartnett
Copy link
Author

@antfu making progress! Different error this time:

failed to load config from .....\vite.config.ts
error when starting dev server:
file:///...../node_modules/.pnpm/[email protected][email protected]/node_modules/unplugin/dist/index.mjs:65
import { dirname, join, resolve } from "upath";
^^^^
SyntaxError: Named export 'join' not found. The requested module 'upath' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'upath';
const { dirname, join, resolve } = pkg;

at ModuleJob._instantiate (internal/modules/esm/module_job.js:121:21)
at async ModuleJob.run (internal/modules/esm/module_job.js:166:5)
at async Loader.import (internal/modules/esm/loader.js:178:24)
at async loadConfigFromFile (.....\node_modules\.pnpm\[email protected]\node_modules\vite\dist\node\chunks\dep-972722fa.js:75819:31)
at async resolveConfig (.....\node_modules\.pnpm\[email protected]\node_modules\vite\dist\node\chunks\dep-972722fa.js:75434:28)
at async createServer (.....\node_modules\.pnpm\[email protected]\node_modules\vite\dist\node\chunks\dep-972722fa.js:73957:20)
at async CAC.<anonymous> (.....\node_modules\.pnpm\[email protected]\node_modules\vite\dist\node\cli.js:13963:24)

 ERROR  Command failed with exit code 1.

@souljorje
Copy link

@antfu can u please make a release with latest fix? and also update unplugin in https://github.com/antfu/unplugin-vue-components

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

3 participants