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

Yarn: node adapter builds with error in entry script #4974

Closed
1 task
Jutanium opened this issue Oct 4, 2022 · 1 comment
Closed
1 task

Yarn: node adapter builds with error in entry script #4974

Jutanium opened this issue Oct 4, 2022 · 1 comment
Labels
- P2: has workaround Bug, but has workaround (priority)

Comments

@Jutanium
Copy link
Contributor

Jutanium commented Oct 4, 2022

What version of astro are you using?

1.4.4

Are you using an SSR adapter? If so, which one?

Node

What package manager are you using?

yarn

What operating system are you using?

Mac

Describe the Bug

After installing the node adapter and running yarn build, the output entry.mjs script contains this line:

import { compile } from 'path-to-regexp';

This results in an error when script is run:

import { compile } from 'path-to-regexp';
^^^^^^^
SyntaxError: Named export 'compile' not found. The requested module 'path-to-regexp' is a CommonJS module, which may not support all module.exports as named exports.

This is fixed by adding path-to-regexp to noExternal before building.

This error does not happen when using npm or pnpm. Yarn seems to build an entirely different entry script, which is shorter but has these additional dependencies.

Yarn:

// entry.mjs
import * as adapter from '@astrojs/node/server.js';
import { escape } from 'html-escaper';
import 'mime';
import 'cookie';
import 'kleur/colors';
import 'string-width';
import 'path-browserify';
import { compile } from 'path-to-regexp';

const ASTRO_VERSION = "1.4.4";
...

pnpm:

// entry.mjs
import * as adapter from '@astrojs/node/server.js';

const ASTRO_VERSION = "1.4.4";

Link to Minimal Reproducible Example

https://github.com/Jutanium/repro-node-yarn

Participation

  • I am willing to submit a pull request for this issue.
@matthewp matthewp added the - P2: has workaround Bug, but has workaround (priority) label Oct 4, 2022
@matthewp
Copy link
Contributor

matthewp commented Oct 6, 2022

Closed by #4978

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority)
Projects
None yet
Development

No branches or pull requests

2 participants