From 08699062d567315af0097578f7114d784cb4012b Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Fri, 23 Jun 2017 09:03:10 -0700 Subject: [PATCH] npm package has `src/` rather than `build/` Summary: We use custom npm scripts (`prepare-release`, `cleanup-release`) to - move `src` to `src.orig`, and `build` to `src` before creating the tarball - move everything back afterwards We run these scripts with lerna before and after publishing. Custom hooks avoid problems with `prepublishOnly` and `postpublish` not being run at opportune times, `prepack` and `postpack` not being supported by npm v4 and yarn, and using `lerna run prepublishOnly` resulting in duplicated execution of the command. This ensures that development is closer to what is pulled in from npm. Reviewed By: jeanlauliac Differential Revision: D5310133 fbshipit-source-id: 6b9885c88b936ef3fe5f1858738ad63d581a8731 --- lerna.json | 2 +- package.json | 3 ++- packages/metro-bundler/.npmignore | 3 ++- packages/metro-bundler/package.json | 6 +++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lerna.json b/lerna.json index d576918e..eec0c140 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { - "lerna": "2.0.0-beta.38", "version": "0.8.1", + "lerna": "2.0.0-rc.5", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/package.json b/package.json index b6fcf326..7641e0b0 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "lint": "eslint . --cache", "lint-fix": "eslint . --fix --cache", "postinstall": "node ./scripts/postinstall.js && node ./scripts/build.js", - "publish": "yarn run build-clean && yarn run build && lerna publish", + "publish": "yarn run build-clean && yarn run build && lerna run prepare-release && lerna publish", + "postpublish": "lerna run cleanup-release", "test-ci": "yarn run typecheck && yarn run lint && yarn run build && yarn run jest-coverage -- -i && node scripts/mapCoverage.js && codecov", "test": "yarn run typecheck && yarn run lint && yarn run build && yarn run jest && yarn run test-examples", "typecheck": "flow check", diff --git a/packages/metro-bundler/.npmignore b/packages/metro-bundler/.npmignore index c8ab4c8d..a0d45702 100644 --- a/packages/metro-bundler/.npmignore +++ b/packages/metro-bundler/.npmignore @@ -1,4 +1,5 @@ **/__mocks__/** **/__tests__/** -src +build +src.real yarn.lock diff --git a/packages/metro-bundler/package.json b/packages/metro-bundler/package.json index eb05b1c8..d33ffeb3 100644 --- a/packages/metro-bundler/package.json +++ b/packages/metro-bundler/package.json @@ -2,11 +2,15 @@ "version": "0.8.1", "name": "metro-bundler", "description": "🚇 The JavaScript bundler for React Native.", - "main": "build/index.js", + "main": "src/index.js", "repository": { "type": "git", "url": "git@github.com:facebook/metro-bundler.git" }, + "scripts": { + "prepare-release": "test -d build && rm -rf src.real && mv src src.real && mv build src", + "cleanup-release": "test ! -e build && mv src build && mv src.real src" + }, "dependencies": { "absolute-path": "^0.0.0", "async": "^2.4.0",