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 Version does not work #147

Closed
denny99 opened this issue Jan 22, 2024 · 4 comments
Closed

ESM Version does not work #147

denny99 opened this issue Jan 22, 2024 · 4 comments

Comments

@denny99
Copy link

denny99 commented Jan 22, 2024

import readPkg from 'read-pkg';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:77:18)
    at wrapSafe (node:internal/modules/cjs/loader:1288:20)
    at Module._compile (node:internal/modules/cjs/loader:1340:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at cjsLoader (node:internal/modules/esm/translators:356:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:305:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
/Users/dennymueller/IdeaProjects/deltastone/ds-nx-plugins/node_modules/semantic-release-monorepo/src/index.js:1

The latest version 8.0.0 does not properly work. See the error above.

Compared to the fork semantic-release-monorepo-esm, all js Files are served as regular .js and not as .mjs. So Node does not know that it should compile it as modules.

@pmowrer
Copy link
Owner

pmowrer commented Jan 22, 2024

Guessing it's because of missing type: module #148

@denny99
Copy link
Author

denny99 commented Jan 23, 2024

Yeah this would be the alternative approach.

You can either specify the whole package as module using the package.json
or explicitly export .mjs Files.

When i tried to manually switch to type: module in the local package.json. Semantic reported "MODULE_NOT_FOUND". But i see that the PR also changes the index.js so this might be the solution.

@wespen
Copy link

wespen commented Jan 23, 2024

Looks like its fixed in #148

@denny99
Copy link
Author

denny99 commented Jan 24, 2024

Yes fixed

@denny99 denny99 closed this as completed Jan 24, 2024
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