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

Rollup Failed to resolve on astrojs/netlify 2.1.0 #6086

Closed
1 task
Deanmv opened this issue Feb 1, 2023 · 4 comments · Fixed by #6090
Closed
1 task

Rollup Failed to resolve on astrojs/netlify 2.1.0 #6086

Deanmv opened this issue Feb 1, 2023 · 4 comments · Fixed by #6090
Assignees
Labels
- P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority)

Comments

@Deanmv
Copy link
Contributor

Deanmv commented Feb 1, 2023

What version of astro are you using?

2.0.5

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

Netlify

What package manager are you using?

pnpm (happens with yarn as well)

What operating system are you using?

Windows

Describe the Bug

When trying to run a build with Astro 2.0.5 and astrojs/netlify 2.1.0, I get the following error:

Rollup failed to resolve import "@netlify/functions" from "{Some file path truncated}/node_modules/.pnpm/@[email protected][email protected]/node_modules/@astrojs/netlify/dist/netlify-functions.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`

To replicate: let the stackblitz attached install, then run yarn astro build to see the error.

This works correctly on Astro 2.0.5 and astrojs/netlify 2.0.0 so it looks like a change in astrojs/netlify 2.1.0 that caused it

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-vkntfd

Participation

  • I am willing to submit a pull request for this issue.
@HiDeoo
Copy link
Member

HiDeoo commented Feb 1, 2023

Just hit the same issue and had to rollback to a previous version.

Couldn't investigate yet a proper solution due to lack of time but it looks like the issue is coming from a change in #5874 transforming a type only import of @netlify/functions into a regular import to bring in builder in packages/integrations/netlify/src/netlify-functions.ts:

- import type { Handler } from '@netlify/functions';
+ import { builder, Handler } from '@netlify/functions';

polilluminato added a commit to polilluminato/wassword-website that referenced this issue Feb 1, 2023
Revert astrojs/netlify version from 2.1.0 to 2.0.0 due to a bug described here withastro/astro#6086
@matthewp
Copy link
Contributor

matthewp commented Feb 1, 2023

Ah, good find @HiDeoo

@matthewp matthewp self-assigned this Feb 1, 2023
@matthewp matthewp added the - P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) label Feb 1, 2023
@polilluminato
Copy link

I everyone I've got the same issue with my newly created Astro website when I'm trying to deploy it on Netlify.

I follow these two guides:

and I also revert the @astrojs/netlify package to ^2.0.0 but the build failed.

This is my package.json:

{
  "name": "@example/basics",
  "type": "module",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "dev": "astro dev",
    "start": "astro dev",
    "build": "astro build",
    "preview": "astro preview",
    "astro": "astro"
  },
  "dependencies": {
    "@astrojs/netlify": "^2.0.0",
    "astro": "^2.0.5"
  }
}

and this is all the build log from Netlify:

7:47:53 PM: build-image version: ada486d80800a9a84b567366a5bfe2beab07892e (focal)
7:47:53 PM: buildbot version: ada486d80800a9a84b567366a5bfe2beab07892e
7:47:53 PM: Fetching cached dependencies
7:47:53 PM: Failed to fetch cache, continuing with build
7:47:53 PM: Starting to prepare the repo for build
7:47:54 PM: No cached dependencies found. Cloning fresh repo
7:47:54 PM: git clone --filter=blob:none https://github.com/polilluminato/wassword-website
7:47:54 PM: Preparing Git Reference refs/heads/main
7:47:54 PM: Parsing package.json dependencies
7:47:56 PM: Starting build script
7:47:56 PM: Installing dependencies
7:47:56 PM: Python version set to 2.7
7:47:56 PM: v16.19.0 is already installed.
7:47:56 PM: Now using node v16.19.0 (npm v8.19.3)
7:47:56 PM: Enabling Node.js Corepack
7:47:56 PM: Started restoring cached build plugins
7:47:56 PM: Finished restoring cached build plugins
7:47:56 PM: Attempting Ruby version 2.7.2, read from environment
7:47:57 PM: Using Ruby version 2.7.2
7:47:57 PM: Using PHP version 8.0
7:47:57 PM: Started restoring cached corepack dependencies
7:47:57 PM: mv: cannot move '/opt/build/cache/.node/corepack' to '/opt/buildhome/.node/corepack': No such file or directory
7:47:57 PM: Finished restoring cached corepack dependencies
7:47:57 PM: No npm workspaces detected
7:47:57 PM: Started restoring cached node modules
7:47:57 PM: Finished restoring cached node modules
7:47:57 PM: Bypassing sha validation. Running pre & post install scripts
7:47:57 PM: Installing npm packages using npm version 8.19.3
7:48:02 PM: added 393 packages, and audited 394 packages in 4s
7:48:02 PM: 160 packages are looking for funding
7:48:02 PM:   run `npm fund` for details
7:48:02 PM: found 0 vulnerabilities
7:48:02 PM: npm packages installed
7:48:02 PM: Started restoring cached go cache
7:48:02 PM: Finished restoring cached go cache
7:48:02 PM: go version go1.19.5 linux/amd64
7:48:02 PM: Detected 1 framework(s)
7:48:02 PM: "astro" at version "2.0.5"
7:48:02 PM: Installing missing commands
7:48:02 PM: Verify run directory
7:48:02 PM: Section completed: initializing
7:48:04 PM: ​
7:48:04 PM:   Netlify Build                                                 
7:48:04 PM: ────────────────────────────────────────────────────────────────
7:48:04 PM: ​
7:48:04 PM: ❯ Version
7:48:04 PM:   @netlify/build 29.5.3
7:48:04 PM: ​
7:48:04 PM: ❯ Flags
7:48:04 PM:   baseRelDir: true
7:48:04 PM:   buildId: 63dab3d779fb6400083b360f
7:48:04 PM:   deployId: 63dab3d779fb6400083b3611
7:48:04 PM: ​
7:48:04 PM: ❯ Current directory
7:48:04 PM:   /opt/build/repo
7:48:04 PM: ​
7:48:04 PM: ❯ Config file
7:48:04 PM:   No config file was defined: using default values.
7:48:04 PM: ​
7:48:04 PM: ❯ Context
7:48:04 PM:   production
7:48:04 PM: ​
7:48:04 PM:   1. Build command from Netlify app                             
7:48:04 PM: ────────────────────────────────────────────────────────────────
7:48:04 PM: ​
7:48:04 PM: $ astro build
7:48:05 PM: 06:48:05 PM [build] output target: server
7:48:05 PM: 06:48:05 PM [build] deploy adapter: @astrojs/netlify/functions
7:48:05 PM: 06:48:05 PM [build] Collecting build info...
7:48:05 PM: 06:48:05 PM [build] Completed in 11ms.
7:48:05 PM: 06:48:05 PM [build] Building server entrypoints...
7:48:05 PM: [vite]: Rollup failed to resolve import "@netlify/functions" from "/opt/build/repo/node_modules/@astrojs/netlify/dist/netlify-functions.js".
7:48:05 PM: This is most likely unintended because it can break your application at runtime.
7:48:05 PM: If you do want to externalize this module explicitly add it to
7:48:05 PM: `build.rollupOptions.external`
7:48:05 PM:  error   [vite]: Rollup failed to resolve import "@netlify/functions" from "/opt/build/repo/node_modules/@astrojs/netlify/dist/netlify-functions.js".
7:48:05 PM:   This is most likely unintended because it can break your application at runtime.
7:48:05 PM:   If you do want to externalize this module explicitly add it to
7:48:05 PM:   `build.rollupOptions.external`
7:48:05 PM: Error: [vite]: Rollup failed to resolve import "@netlify/functions" from "/opt/build/repo/node_modules/@astrojs/netlify/dist/netlify-functions.js".
7:48:05 PM: This is most likely unintended because it can break your application at runtime.
7:48:05 PM: If you do want to externalize this module explicitly add it to
7:48:05 PM: `build.rollupOptions.external`
7:48:05 PM:     at onRollupWarning (file:///opt/build/repo/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:44636:19)
7:48:05 PM:     at onwarn (file:///opt/build/repo/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:44407:13)
7:48:05 PM:     at Object.onwarn (file:///opt/build/repo/node_modules/rollup/dist/es/shared/rollup.js:24537:13)
7:48:05 PM:     at ModuleLoader.handleInvalidResolvedId (file:///opt/build/repo/node_modules/rollup/dist/es/shared/rollup.js:23221:26)
7:48:05 PM:     at file:///opt/build/repo/node_modules/rollup/dist/es/shared/rollup.js:23181:26
7:48:05 PM: ​
7:48:05 PM:   "build.command" failed                                        
7:48:05 PM: ────────────────────────────────────────────────────────────────
7:48:05 PM: ​
7:48:05 PM:   Error message
7:48:05 PM:   Command failed with exit code 1: astro build (https://ntl.fyi/exit-code-1)
7:48:05 PM: ​
7:48:05 PM:   Error location
7:48:05 PM:   In Build command from Netlify app:
7:48:05 PM:   astro build
7:48:05 PM: ​
7:48:05 PM:   Resolved config
7:48:06 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
7:48:05 PM:   build:
7:48:05 PM:     command: astro build
7:48:05 PM:     commandOrigin: ui
7:48:05 PM:     publish: /opt/build/repo/dist
7:48:05 PM:     publishOrigin: ui
7:48:05 PM: Caching artifacts
7:48:05 PM: Started saving node modules
7:48:05 PM: Finished saving node modules
7:48:05 PM: Started saving build plugins
7:48:05 PM: Finished saving build plugins
7:48:05 PM: Started saving pip cache
7:48:05 PM: Finished saving pip cache
7:48:05 PM: Started saving emacs cask dependencies
7:48:05 PM: Finished saving emacs cask dependencies
7:48:05 PM: Started saving maven dependencies
7:48:05 PM: Finished saving maven dependencies
7:48:05 PM: Started saving boot dependencies
7:48:05 PM: Finished saving boot dependencies
7:48:05 PM: Started saving rust rustup cache
7:48:05 PM: Finished saving rust rustup cache
7:48:05 PM: Started saving go dependencies
7:48:05 PM: Finished saving go dependencies
7:48:06 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
7:48:06 PM: Failing build: Failed to build site
7:48:06 PM: Finished processing build request in 12.955s

Bye, Alberto

@matthewp
Copy link
Contributor

matthewp commented Feb 1, 2023

Fixing here: #6090

polilluminato added a commit to polilluminato/wassword-website that referenced this issue Feb 2, 2023
Update @astrojs/netlify version from 2.0.0
to 2.1.1 to resolve this issue with Netlify Deploy
withastro/astro#6086
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants