diff --git a/packages/embark/.babelrc.js b/packages/embark/.babelrc.js index c4f988159..5bb1ef830 100644 --- a/packages/embark/.babelrc.js +++ b/packages/embark/.babelrc.js @@ -43,22 +43,16 @@ module.exports = (api) => { const base = {}; const node = cloneDeep(base); - Object.assign(node, { - ignore: [ - 'src/lib/modules/basic-pipeline/babel-loader-overrides.js', - 'src/lib/modules/basic-pipeline/webpack.config.js' - ] - }); if (env === 'node') { - copyFiles(node.ignore); + copyFiles(node.ignore || []); return node; } const test = cloneDeep(node); if (env === 'test') { - copyFiles(test.ignore); + copyFiles(test.ignore || []); return test; } diff --git a/packages/embark/package.json b/packages/embark/package.json index 56643fb1d..675d37385 100644 --- a/packages/embark/package.json +++ b/packages/embark/package.json @@ -94,6 +94,7 @@ "embark-accounts-manager": "^4.1.1", "embark-api": "^4.1.1", "embark-authenticator": "^4.1.1", + "embark-basic-pipeline": "^4.1.1", "embark-code-runner": "^4.1.1", "embark-communication": "^4.1.1", "embark-compiler": "^4.1.1", @@ -207,7 +208,6 @@ "web3-providers-ws": "1.2.1", "web3-shh": "1.2.1", "web3-utils": "1.2.1", - "webpack": "4.41.0", "window-size": "1.1.1", "ws": "7.1.2", "yo-yoify": "4.3.0" diff --git a/packages/embark/src/lib/core/engine.js b/packages/embark/src/lib/core/engine.js index 205ac2551..65540b6fb 100644 --- a/packages/embark/src/lib/core/engine.js +++ b/packages/embark/src/lib/core/engine.js @@ -114,7 +114,7 @@ class Engine { } pipelineService(_options) { - this.registerModule('basic-pipeline', { + this.registerModulePackage('embark-basic-pipeline', { plugins: this.plugins, webpackConfigName: this.webpackConfigName, useDashboard: this.useDashboard diff --git a/packages/plugins/basic-pipeline/.babelrc.js b/packages/plugins/basic-pipeline/.babelrc.js new file mode 100644 index 000000000..2b236d313 --- /dev/null +++ b/packages/plugins/basic-pipeline/.babelrc.js @@ -0,0 +1,66 @@ +/* global __dirname module require */ + +const cloneDeep = require('lodash.clonedeep'); +const {copySync, ensureDirSync} = require('fs-extra'); +const glob = require('glob'); +const {dirname, join, relative} = require('path'); + +// @babel/cli v7's --copy-files option does not work well together with +// config-specified ignore paths, and that's a problem for embark-collective +// actions since the @babel/cli invocation must be the same across all packages +// in the collective; so any package in the collective that excludes src/ files +// from transpilation via its package-local .babelrc.js should copy those files +// into dist/, but only if they are expected to be in dist/; .babelrc.js should +// also copy any non .js,.ts files into /dist + +// in this case we want the un-transpiled webpack config and babel-loader +// overrides script from the basic-pipeline to be copied into the respective +// subdir in dist/; we also want to copy .ejs and .json files + +function copyFiles (ignored) { + const others = glob.sync( + join(__dirname, 'src/**/*.*'), + {ignore: [ + join(__dirname, 'src/**/*.js'), + join(__dirname, 'src/**/*.ts'), + join(__dirname, 'src/**/*.disabled') + ]} + ).map(path => relative(__dirname, path)); + + ignored = ignored.concat(others); + ignored + .map(path => path.replace('src/', 'dist/')) + .forEach((dest, index) => { + ensureDirSync(dirname(join(__dirname, dest))); + const source = ignored[index]; + copySync(join(__dirname, source), join(__dirname, dest)); + }); +} + +module.exports = (api) => { + const env = api.env(); + + const base = {}; + + const node = cloneDeep(base); + Object.assign(node, { + ignore: [ + 'src/babel-loader-overrides.js', + 'src/webpack.config.js' + ] + }); + + if (env === 'node') { + copyFiles(node.ignore); + return node; + } + + const test = cloneDeep(node); + + if (env === 'test') { + copyFiles(test.ignore); + return test; + } + + return base; +}; diff --git a/packages/plugins/basic-pipeline/.npmrc b/packages/plugins/basic-pipeline/.npmrc new file mode 100644 index 000000000..e031d3432 --- /dev/null +++ b/packages/plugins/basic-pipeline/.npmrc @@ -0,0 +1,4 @@ +engine-strict = true +package-lock = false +save-exact = true +scripts-prepend-node-path = true diff --git a/packages/plugins/basic-pipeline/README.md b/packages/plugins/basic-pipeline/README.md new file mode 100644 index 000000000..a9de3c92e --- /dev/null +++ b/packages/plugins/basic-pipeline/README.md @@ -0,0 +1,8 @@ +# `embark-basic-pipeline` + +> Basic pipeline for Embark that builds a DApp's frontend assets using webpack + +Visit [embark.status.im](https://embark.status.im/) to get started with +[Embark](https://github.com/embark-framework/embark). + +Contracts in `test/fixture/contracts` are from [OpenZeppelin](https://github.com/OpenZeppelin/openzeppelin-solidity) and [Gnosis Prediction Markets](https://github.com/gnosis/pm-contracts) diff --git a/packages/plugins/basic-pipeline/package.json b/packages/plugins/basic-pipeline/package.json new file mode 100644 index 000000000..f16f92141 --- /dev/null +++ b/packages/plugins/basic-pipeline/package.json @@ -0,0 +1,84 @@ +{ + "name": "embark-basic-pipeline", + "version": "4.1.1", + "author": "Iuri Matias ", + "contributors": [], + "description": "Basic pipeline for Embark that builds a DApp's frontend assets using webpack", + "homepage": "https://github.com/embark-framework/embark/tree/master/packages/plugins/basic-pipeline#readme", + "bugs": "https://github.com/embark-framework/embark/issues", + "keywords": [ + "blockchain", + "dapps", + "ethereum", + "ipfs", + "serverless", + "solc", + "solidity" + ], + "files": [ + "dist" + ], + "license": "MIT", + "repository": { + "directory": "packages/plugins/basic-pipeline", + "type": "git", + "url": "https://github.com/embark-framework/embark.git" + }, + "main": "./dist/index.js", + "embark-collective": { + "build:node": true + }, + "scripts": { + "_build": "npm run solo -- build", + "ci": "npm run qa", + "clean": "npm run reset", + "lint": "eslint src/", + "qa": "npm-run-all lint _build", + "reset": "npx rimraf dist embark-*.tgz package", + "solo": "embark-solo", + "test": "jest" + }, + "eslintConfig": { + "extends": "../../../.eslintrc.json" + }, + "dependencies": { + "@babel/runtime-corejs2": "7.6.2", + "async": "2.6.1", + "clone-deep": "4.0.0", + "embark-core": "^4.1.1", + "embark-i18n": "^4.1.1", + "embark-utils": "^4.1.1", + "fs-extra": "8.1.0", + "webpack": "4.41.0" + }, + "devDependencies": { + "@babel/core": "7.6.2", + "babel-jest": "24.9.0", + "embark-solo": "^4.1.1", + "embark-testing": "^4.1.1", + "eslint": "5.7.0", + "jest": "24.9.0", + "npm-run-all": "4.1.5", + "rimraf": "3.0.0" + }, + "engines": { + "node": ">=8.12.0 <12.0.0", + "npm": ">=6.4.1", + "yarn": ">=1.12.3" + }, + "jest": { + "collectCoverage": true, + "testEnvironment": "node", + "testMatch": [ + "**/test/**/*.js" + ], + "transform": { + "\\.js$": [ + "babel-jest", + { + "rootMode": "upward" + } + ] + } + } +} diff --git a/packages/embark/src/lib/modules/basic-pipeline/babel-loader-overrides.js b/packages/plugins/basic-pipeline/src/babel-loader-overrides.js similarity index 100% rename from packages/embark/src/lib/modules/basic-pipeline/babel-loader-overrides.js rename to packages/plugins/basic-pipeline/src/babel-loader-overrides.js diff --git a/packages/embark/src/lib/modules/basic-pipeline/index.js b/packages/plugins/basic-pipeline/src/index.js similarity index 100% rename from packages/embark/src/lib/modules/basic-pipeline/index.js rename to packages/plugins/basic-pipeline/src/index.js diff --git a/packages/embark/src/lib/modules/basic-pipeline/webpack.config.js b/packages/plugins/basic-pipeline/src/webpack.config.js similarity index 100% rename from packages/embark/src/lib/modules/basic-pipeline/webpack.config.js rename to packages/plugins/basic-pipeline/src/webpack.config.js diff --git a/packages/embark/src/lib/modules/basic-pipeline/webpackConfigReader.js b/packages/plugins/basic-pipeline/src/webpackConfigReader.js similarity index 100% rename from packages/embark/src/lib/modules/basic-pipeline/webpackConfigReader.js rename to packages/plugins/basic-pipeline/src/webpackConfigReader.js diff --git a/packages/embark/src/lib/modules/basic-pipeline/webpackProcess.js b/packages/plugins/basic-pipeline/src/webpackProcess.js similarity index 100% rename from packages/embark/src/lib/modules/basic-pipeline/webpackProcess.js rename to packages/plugins/basic-pipeline/src/webpackProcess.js