Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions buildpacks/nodejs-pnpm-install/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- New symlink from {virtual_layer}/node_modules to {app_dir}/node_modules to
support transitory dependency resolution and nuxt apps.
([#737](https://github.com/heroku/buildpacks-nodejs/pull/737))

### Changed

- Virtual store artifact location has moved form {virtual_layer}/* to
{virtual_layer}/store/* to support transitory dependency resolution and
nuxt apps. ([#737](https://github.com/heroku/buildpacks-nodejs/pull/737))

## [2.3.0] - 2023-11-09

- No changes.
Expand Down
11 changes: 11 additions & 0 deletions buildpacks/nodejs-pnpm-install/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ fn on_buildpack_error(bp_err: PnpmInstallBuildpackError) {
"},
);
}
PnpmInstallBuildpackError::VirtualLayer(err) => {
log_error(
"heroku/nodejs-pnpm-install virtual store layer error",
formatdoc! {"
There was an error while attempting to create the virtual
store layer for pnpm's installed dependencies.

Details: {err:?}
"},
);
}
};
}

Expand Down
20 changes: 18 additions & 2 deletions buildpacks/nodejs-pnpm-install/src/layers/virtual_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use libcnb::data::layer_content_metadata::LayerTypes;
use libcnb::generic::GenericMetadata;
use libcnb::layer::{Layer, LayerResult, LayerResultBuilder};
use libherokubuildpack::log::log_info;
use std::fs::create_dir;
use std::os::unix::fs::symlink;
use std::path::Path;

/// `VirtualStoreLayer` is a layer for the pnpm virtual store. It's contents
Expand All @@ -26,10 +28,24 @@ impl Layer for VirtualStoreLayer {

fn create(
&self,
_context: &BuildContext<Self::Buildpack>,
_layer_path: &Path,
context: &BuildContext<Self::Buildpack>,
layer_path: &Path,
) -> Result<LayerResult<Self::Metadata>, PnpmInstallBuildpackError> {
log_info("Creating pnpm virtual store");

// Create a directory for dependencies in the virtual store.
create_dir(layer_path.join("store")).map_err(PnpmInstallBuildpackError::VirtualLayer)?;

// Install a symlink from {virtual_layer}/node_modules to
// {app_dir}/node_modules, so that dependencies in
// {virtual_layer}/store/ can find their dependencies via the Node
// module loader's ancestor directory traversal.
symlink(
context.app_dir.join("node_modules"),
layer_path.join("node_modules"),
)
.map_err(PnpmInstallBuildpackError::VirtualLayer)?;

LayerResultBuilder::new(GenericMetadata::default()).build()
}
}
3 changes: 2 additions & 1 deletion buildpacks/nodejs-pnpm-install/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl Buildpack for PnpmInstallBuildpack {

cmd::pnpm_set_store_dir(&env, &addressable_layer.path)
.map_err(PnpmInstallBuildpackError::PnpmDir)?;
cmd::pnpm_set_virtual_dir(&env, &virtual_layer.path)
cmd::pnpm_set_virtual_dir(&env, &virtual_layer.path.join("store"))
.map_err(PnpmInstallBuildpackError::PnpmDir)?;

log_header("Installing dependencies");
Expand Down Expand Up @@ -116,6 +116,7 @@ enum PnpmInstallBuildpackError {
PnpmDir(cmd::Error),
PnpmInstall(cmd::Error),
PnpmStorePrune(cmd::Error),
VirtualLayer(std::io::Error),
}

impl From<PnpmInstallBuildpackError> for libcnb::Error<PnpmInstallBuildpackError> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist

# Node dependencies
node_modules

# Logs
logs
*.log

# Misc
.DS_Store
.fleet
.idea

# Local env files
.env
.env.*
!.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shamefully-hoist=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Nuxt 3 Minimal Starter

Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.

## Setup

Make sure to install the dependencies:

```bash
# npm
npm install

# pnpm
pnpm install

# yarn
yarn install

# bun
bun install
```

## Development Server

Start the development server on `http://localhost:3000`:

```bash
# npm
npm run dev

# pnpm
pnpm run dev

# yarn
yarn dev

# bun
bun run dev
```

## Production

Build the application for production:

```bash
# npm
npm run build

# pnpm
pnpm run build

# yarn
yarn build

# bun
bun run build
```

Locally preview production build:

```bash
# npm
npm run preview

# pnpm
pnpm run preview

# yarn
yarn preview

# bun
bun run preview
```

Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
<NuxtWelcome />
</div>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true }
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "pnpm-8-nuxt",
"private": true,
"packageManager": "[email protected]",
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"start": "node .output/server/index.mjs"
},
"devDependencies": {
"@nuxt/devtools": "latest",
"nuxt": "^3.8.2",
"vue": "^3.3.8",
"vue-router": "^4.2.5"
}
}
Loading