Skip to content

Commit

Permalink
build: move CJS package creation scripts to top-level scripts/ folder
Browse files Browse the repository at this point in the history
  • Loading branch information
darthtrevino committed Jun 21, 2019
1 parent 0db6845 commit 5e3c52c
Show file tree
Hide file tree
Showing 17 changed files with 302 additions and 19 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Expand Up @@ -8,6 +8,3 @@ __site_prerender__
coverage
test-results.xml
*-*.log
packages/alternative_builds/cjs/
!packages/alternative_builds/cjs/*.js
!packages/alternative_builds/cjs/*.json
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -35,7 +35,7 @@
"scripts": {
"clean": "lerna run clean",
"build:packages": "lerna run build --stream",
"build:cjs": "node packages/alternative_builds/cjs/execute_replacements.js",
"build:cjs": "node scripts/execute_cjs_replacements.js",
"build": "run-s build:packages build:cjs",
"unit_test": "jest",
"jest:watch": "jest --watch",
Expand All @@ -47,7 +47,7 @@
"prettify": "prettier 'packages/*/**/*.js' 'examples/**/*.js' 'site/**/*.js'",
"precommit": "lint-staged",
"prepublishOnly": "npm test",
"preinstall": "node packages/alternative_builds/cjs/create_cjs_modules.js",
"preinstall": "node scripts/create_cjs_modules.js",
"start": "lerna run --parallel --stream start",
"start_docs": "lerna run --stream start --scope react-dnd-documentation",
"watch": "lerna run --parallel --stream watch"
Expand Down
@@ -0,0 +1 @@
The CJS Packages here are dynamically generated. Manula edits to them will be destroyed.
25 changes: 25 additions & 0 deletions packages/alternative_builds/cjs/dnd-core/package.json
@@ -0,0 +1,25 @@
{
"name": "dnd-core-cjs",
"version": "8.0.3",
"license": "MIT",
"description": "Drag and drop sans the GUI",
"main": "./lib/index.js",
"scripts": {
"build": "tsc",
"clean": "rimraf lib"
},
"dependencies": {
"@types/asap": "^2.0.0",
"@types/invariant": "^2.2.29",
"asap": "^2.0.6",
"invariant": "^2.2.4",
"redux": "^4.0.1"
},
"devDependencies": {
"npm-run-all": "^4.1.5",
"rimraf": "^2.6.3",
"typescript": "^3.5.2",
"dnd-core": "8.0.3"
},
"peerDependencies": {}
}
30 changes: 30 additions & 0 deletions packages/alternative_builds/cjs/dnd-core/tsconfig.json
@@ -0,0 +1,30 @@
{
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "lib",
"esModuleInterop": true,
"baseUrl": "/Users/christrevino/Workspace/oss/react-dnd/packages/core/dnd-core/",
"paths": {
"dnd-core": [
"../../core/dnd-core/lib/index.d.ts"
],
"react-dnd": [
"../../core/react-dnd/lib/index.d.ts"
],
"react-dnd-html5-backend": [
"../../core/html5-backend/lib/index.d.ts"
],
"react-dnd-test-backend": [
"../../testing/test-backend/lib/index.d.ts"
],
"react-dnd-test-utils": [
"../../testing/test-utils/lib/index.d.ts"
]
}
},
"files": [
"/Users/christrevino/Workspace/oss/react-dnd/packages/core/dnd-core/src/index.ts"
]
}
26 changes: 26 additions & 0 deletions packages/alternative_builds/cjs/html5-backend/package.json
@@ -0,0 +1,26 @@
{
"name": "react-dnd-html5-backend-cjs",
"version": "8.0.3",
"license": "MIT",
"description": "HTML5 backend for React DnD",
"main": "lib/index.js",
"scripts": {
"build": "tsc",
"clean": "rimraf lib"
},
"dependencies": {
"dnd-core-cjs": "^8.0.3"
},
"devDependencies": {
"@types/react": "^16.8.19",
"npm-run-all": "^4.1.5",
"react": "^16.8.6",
"react-dnd-test-backend": "^8.0.3",
"react-dom": "^16.8.6",
"rimraf": "^2.6.3",
"ts-loader": "^6.0.2",
"typescript": "^3.5.2",
"react-dnd-html5-backend": "8.0.3"
},
"peerDependencies": {}
}
30 changes: 30 additions & 0 deletions packages/alternative_builds/cjs/html5-backend/tsconfig.json
@@ -0,0 +1,30 @@
{
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "lib",
"esModuleInterop": true,
"baseUrl": "/Users/christrevino/Workspace/oss/react-dnd/packages/core/html5-backend/",
"paths": {
"dnd-core": [
"../../core/dnd-core/lib/index.d.ts"
],
"react-dnd": [
"../../core/react-dnd/lib/index.d.ts"
],
"react-dnd-html5-backend": [
"../../core/html5-backend/lib/index.d.ts"
],
"react-dnd-test-backend": [
"../../testing/test-backend/lib/index.d.ts"
],
"react-dnd-test-utils": [
"../../testing/test-utils/lib/index.d.ts"
]
}
},
"files": [
"/Users/christrevino/Workspace/oss/react-dnd/packages/core/html5-backend/src/index.ts"
]
}
38 changes: 38 additions & 0 deletions packages/alternative_builds/cjs/react-dnd/package.json
@@ -0,0 +1,38 @@
{
"name": "react-dnd-cjs",
"version": "8.0.3",
"license": "MIT",
"description": "Drag and Drop for React",
"main": "lib/index.js",
"scripts": {
"build": "tsc",
"clean": "rimraf lib"
},
"dependencies": {
"@types/hoist-non-react-statics": "^3.3.1",
"@types/shallowequal": "^1.1.1",
"hoist-non-react-statics": "^3.3.0",
"shallowequal": "^1.1.0",
"dnd-core-cjs": "^8.0.3"
},
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@types/react": "^16.8.19",
"@types/react-dom": "^16.8.4",
"babel-jest": "^24.8.0",
"babel-loader": "^8.0.6",
"npm-run-all": "^4.1.5",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"rimraf": "^2.6.3",
"ts-loader": "^6.0.2",
"typescript": "^3.5.2",
"react-dnd": "8.0.3"
},
"peerDependencies": {
"react": ">= 16.8",
"react-dom": ">= 16.8"
}
}
30 changes: 30 additions & 0 deletions packages/alternative_builds/cjs/react-dnd/tsconfig.json
@@ -0,0 +1,30 @@
{
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "lib",
"esModuleInterop": true,
"baseUrl": "/Users/christrevino/Workspace/oss/react-dnd/packages/core/react-dnd/",
"paths": {
"dnd-core": [
"../../core/dnd-core/lib/index.d.ts"
],
"react-dnd": [
"../../core/react-dnd/lib/index.d.ts"
],
"react-dnd-html5-backend": [
"../../core/html5-backend/lib/index.d.ts"
],
"react-dnd-test-backend": [
"../../testing/test-backend/lib/index.d.ts"
],
"react-dnd-test-utils": [
"../../testing/test-utils/lib/index.d.ts"
]
}
},
"files": [
"/Users/christrevino/Workspace/oss/react-dnd/packages/core/react-dnd/src/index.ts"
]
}
21 changes: 21 additions & 0 deletions packages/alternative_builds/cjs/test-backend/package.json
@@ -0,0 +1,21 @@
{
"name": "react-dnd-test-backend-cjs",
"version": "8.0.3",
"license": "MIT",
"description": "A mock backend for testing React DnD apps",
"main": "lib/index.js",
"scripts": {
"build": "tsc",
"clean": "rimraf lib"
},
"dependencies": {
"dnd-core-cjs": "^8.0.3"
},
"devDependencies": {
"npm-run-all": "^4.1.5",
"rimraf": "^2.6.3",
"typescript": "^3.5.2",
"react-dnd-test-backend": "8.0.3"
},
"peerDependencies": {}
}
30 changes: 30 additions & 0 deletions packages/alternative_builds/cjs/test-backend/tsconfig.json
@@ -0,0 +1,30 @@
{
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "lib",
"esModuleInterop": true,
"baseUrl": "/Users/christrevino/Workspace/oss/react-dnd/packages/testing/test-backend/",
"paths": {
"dnd-core": [
"../../core/dnd-core/lib/index.d.ts"
],
"react-dnd": [
"../../core/react-dnd/lib/index.d.ts"
],
"react-dnd-html5-backend": [
"../../core/html5-backend/lib/index.d.ts"
],
"react-dnd-test-backend": [
"../../testing/test-backend/lib/index.d.ts"
],
"react-dnd-test-utils": [
"../../testing/test-utils/lib/index.d.ts"
]
}
},
"files": [
"/Users/christrevino/Workspace/oss/react-dnd/packages/testing/test-backend/src/index.ts"
]
}
27 changes: 27 additions & 0 deletions packages/alternative_builds/cjs/test-utils/package.json
@@ -0,0 +1,27 @@
{
"name": "react-dnd-test-utils-cjs",
"version": "8.0.3",
"license": "MIT",
"main": "lib/index.js",
"scripts": {
"build": "tsc",
"clean": "rimraf lib"
},
"dependencies": {},
"devDependencies": {
"npm-run-all": "^4.1.5",
"react": "^16.8.6",
"react-dnd": "^8.0.3",
"react-dnd-test-backend": "^8.0.3",
"react-dom": "^16.8.6",
"rimraf": "^2.6.3",
"typescript": "^3.5.2",
"react-dnd-test-utils": "8.0.3"
},
"peerDependencies": {
"react": ">= 16.8.5",
"react-dom": ">= 16.8.5",
"react-dnd-cjs": "^7.3.2",
"react-dnd-test-backend-cjs": "^7.2.0"
}
}
30 changes: 30 additions & 0 deletions packages/alternative_builds/cjs/test-utils/tsconfig.json
@@ -0,0 +1,30 @@
{
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "lib",
"esModuleInterop": true,
"baseUrl": "/Users/christrevino/Workspace/oss/react-dnd/packages/testing/test-utils/",
"paths": {
"dnd-core": [
"../../core/dnd-core/lib/index.d.ts"
],
"react-dnd": [
"../../core/react-dnd/lib/index.d.ts"
],
"react-dnd-html5-backend": [
"../../core/html5-backend/lib/index.d.ts"
],
"react-dnd-test-backend": [
"../../testing/test-backend/lib/index.d.ts"
],
"react-dnd-test-utils": [
"../../testing/test-utils/lib/index.d.ts"
]
}
},
"files": [
"/Users/christrevino/Workspace/oss/react-dnd/packages/testing/test-utils/src/index.ts"
]
}
8 changes: 0 additions & 8 deletions packages/alternative_builds/cjs/tsconfig.json

This file was deleted.

Expand Up @@ -19,14 +19,16 @@ function deleteFolderRecursive(filePath) {
}
}

const cjsRoot = path.join(__dirname, '../packages/alternative_builds/cjs')

const coreRoots = [
path.join(__dirname, '../../core'),
path.join(__dirname, '../../testing'),
path.join(__dirname, '../packages/core'),
path.join(__dirname, '../packages/testing'),
]
coreRoots.forEach(coreRoot => {
const corePackages = fs.readdirSync(coreRoot)
corePackages.forEach(corePackage => {
const cjsPackageRoot = path.join(__dirname, corePackage)
const cjsPackageRoot = path.join(cjsRoot, corePackage)
if (fs.existsSync(cjsPackageRoot)) {
deleteFolderRecursive(cjsPackageRoot)
}
Expand Down Expand Up @@ -82,9 +84,12 @@ coreRoots.forEach(coreRoot => {
)

const tsConfigJson = {
extends: '../tsconfig.json',
extends: '../../../../../tsconfig.base.json',
compilerOptions: {
target: 'es5',
module: 'commonjs',
outDir: 'lib',
esModuleInterop: true,
baseUrl: `${coreRoot}/${corePackage}/`,
paths: {
'dnd-core': ['../../core/dnd-core/lib/index.d.ts'],
Expand Down
File renamed without changes.
Expand Up @@ -3,10 +3,11 @@ const fs = require('fs')
const path = require('path')
const replace = require('replace-in-file')
const esmLibs = require('./esm-libs')
const cjsRoot = path.join(__dirname, '../packages/alternative_builds/cjs')

const files = fs.readdirSync(__dirname)
const files = fs.readdirSync(cjsRoot)
files.forEach(file => {
const subdir = path.join(__dirname, file)
const subdir = path.join(cjsRoot, file)
if (fs.lstatSync(subdir).isDirectory()) {
console.log(`process module requires in ${subdir}`)
const jsReplaceSpec = {
Expand Down

0 comments on commit 5e3c52c

Please sign in to comment.