I have a small Cloud Build pipeline with a build process to publish a private npm package to Artifact Registry.
My problem is that upon npm publish
, the dist folder is systematically removed from the package.
I have ensured that:
- I have a
.npmignore
file present in my repo that supersedes the.gitignore
file and does not listdist
- I have a
files
entry in mypackage.json
that references thedist
folder and its content (though that is not strictly required since I have a.npmignore
- I have added the
--no-git-tag-version
to my publish command as per this discussion.
Things to note:
- I am working in the context of a mono repo and executing my command from the root of the repo with the
-w
flag - When using the same commands I use in the pipeline locally, the publishing does work and publishes the
dist
folder.
My yaml file:
steps:
- name: node:16
entrypoint: npm
args: ["run", "artifactregistry-login"]
- name: node:16
entrypoint: npm
args: ["install"]
- name: node:16
entrypoint: npm
args:
["-w", "@myapp/config", "version", "0.0.1${_PRE_ID_STRING}.$COMMIT_SHA"]
- name: node:16
dir: "packages/config"
entrypoint: npm
args: ["run", "build"]
- name: "gcr.io/cloud-builders/gcloud"
dir: "packages/config"
entrypoint: bash
args:
- "-c"
- |
find . -type f ! -name "package.json" -delete
rm -rf src
rm -rf tsconfig
# Quick check to see if dist is there at this point and it is.
- name: "gcr.io/cloud-builders/gcloud"
dir: "packages/config"
entrypoint: bash
args:
- "-c"
- |
echo "---before publish---"
ls -lia
cd ./dist
- name: node:16
entrypoint: npm
args: ["-w", "@myapp/config", "publish", "--no-git-tag-version"]
substitutions:
_PRE_ID_STRING: ""
options:
substitution_option: "ALLOW_LOOSE"
timeout: "1000s"
And the package.json (with a desperate attempt to capture my dist contents with an awful glob pattern):
{
"name": "@myapp/config",
"version": "xxxx",
"license": "MIT",
"scripts": {
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:esm": "tsc -p tsconfig.esm.json",
"build": "npm run build:cjs && npm run build:esm"
},
"exports": {
".": {
"import": "./dist/esm/src/index.js",
"require": "./dist/cjs/src/index.js"
},
},
"types": "./dist/cjs/src/index.d.ts",
"publishConfig": {
"access": "restricted",
"registry": "https://europe-west2-npm.pkg.dev"
},
"files": [
"dist/**/*",
"./dist/**/*",
"./dist/**/**/*",
"./dist/**/**/**/*",
"./dist/**/**/*",
"./dist/**/**/**/*",
"dist/**/*",
"dist/**/**/*",
"dist/**/**/**/*",
"dist/**/**/*",
"dist/**/**/**/*"
]
}
Any idea would be massively appreciated.
Thanks,