aws / aws/aws-lambda-builders

Node.js: Built projects contain the absolute path of the build directory

Aperta
#187 0 commenti 2 reazioni 0 assegnatari Vedi su GitHub
area/workflow/node_npm maintainer/need-response type/feature
Lingua principale
Python
Stelle
380
Fork
161
Merge medio
1g 1h
PR unite (30g)
2

Descrizione

**Description:**

This is more of a feature request, so apologies if this doesn't belong here. Many versions ago NPM introduced adding metadata into `package.json` when building a project. As far as I can tell it was done as an extension point that future version could use, see [1] for more details. The problem is that one of the added pieces of metadata is the absolute location of where the project was built, which in itself isn't great but coupled with the fact that SAM uses a directory hash for tracking changes and that AWS CodeBuild uses ephemeral build directories means that files will always appear to have changed even when the only thing that's changed is the location of the build directory. While it doesn't look like NPM will fix the issue any time soon my hope was that the Node lambda builder can run a command after build to remove the metadata. As the metadata isn't used by NPM this is currently completely safe. In fact my current workaround uses [2] to remove the metadata after running `sam build`. I am happy to submit a PR if it's deemed appropriate, although it might take some time due to work commitments.

[1] https://github.com/npm/npm/issues/10393
[2] https://www.npmjs.com/package/removeNPMAbsolutePaths

**Steps to reproduce the issue:**
1. Run `sam build` on an NPM project with external dependencies
2. In the `build` directory, in `node_modules`, look at a `package.json`

**Observed result:**

You will see properties such as `"_where": "/Users/jshore/Documents/Projects/weewikipaint",` containing the absolute path of build directory.

**Expected result:**

A build should be idempotent and not dependent on build location.

**Additional environment details (Ex: Windows, Mac, Amazon Linux etc)**

Reproducible on both Mac and Amazon Linux

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con il percorso del builder Node.js Lambda utilizzato da `sam build`, quindi riproduci il problema con un progetto NPM che abbia dipendenze esterne. Ispeziona i file `package.json` sotto `build/node_modules` per `_where` e i relativi metadati dei percorsi assoluti; il lavoro è completato quando build ripetute da directory diverse producono un output indipendente dalla posizione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
node.js
Ambito
build-system
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.