-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): bundle package to workaround node_moduless tree resolution…
… problems with npm
- Loading branch information
Showing
5 changed files
with
155 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
{ | ||
"presets": [["babel-preset-gatsby-package"]] | ||
"presets": [ | ||
[ | ||
"@babel/env", | ||
{ | ||
"modules": false, | ||
"shippedProposals": true, | ||
"targets": { "node": "10.13.0" } | ||
} | ||
], | ||
"@babel/preset-react" | ||
], | ||
"plugins": ["@babel/plugin-transform-runtime"], | ||
"overrides": [ | ||
{ | ||
"test": ["**/*.ts", "**/*.tsx"], | ||
"plugins": [["@babel/plugin-transform-typescript", { "isTSX": true }]] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// This being a babel.config.js file instead of a .babelrc file allows the | ||
// packages in `internal-plugins` to be compiled with the rest of the source. | ||
// Ref: https://github.com/babel/babel/pull/7358 | ||
|
||
const configPath = require(`path`).join(__dirname, `..`, `..`, `.babelrc.js`) | ||
|
||
module.exports = require(configPath) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import resolve from "@rollup/plugin-node-resolve" | ||
import babel from "@rollup/plugin-babel" | ||
import commonjs from "@rollup/plugin-commonjs" | ||
import json from "@rollup/plugin-json" | ||
import replace from "@rollup/plugin-replace"; | ||
import autoExternal from "rollup-plugin-auto-external" | ||
import internal from "rollup-plugin-internal" | ||
|
||
import path from "path" | ||
|
||
// Rollup hoists Ink's dynamic require of react-devtools-core which causes | ||
// a window not found error so we exclude Ink's devtools file for now. | ||
function excludeDevTools() { | ||
const re = /ink/ | ||
return { | ||
name: `ignoreDevTools`, | ||
|
||
load(id) { | ||
if (id.match(re)) { | ||
if (path.parse(id).name === `devtools`) { | ||
return { code: `` } | ||
} | ||
} | ||
}, | ||
} | ||
} | ||
|
||
export default { | ||
input: `src/reporter/loggers/ink/index.tsx`, | ||
output: { | ||
file: `lib/reporter/loggers/ink/index.js`, | ||
format: `cjs`, | ||
}, | ||
cache: false, | ||
plugins: [ | ||
replace({ | ||
values: { | ||
"process.env.NODE_ENV": JSON.stringify(`production`) | ||
} | ||
}), | ||
excludeDevTools(), | ||
json(), | ||
babel({ | ||
extensions: [`.js`, `.jsx`, `.es6`, `.es`, `.mjs`, `.ts`, `.tsx`] , | ||
babelHelpers: `runtime`, | ||
skipPreflightCheck: true, | ||
exclude: `node_modules/**`, | ||
}), | ||
resolve({ | ||
extensions: [`.mjs`, `.js`, `.json`, `.node`, `.ts`, `.tsx`], | ||
dedupe: [ `react`, `ink` ] | ||
}), | ||
commonjs(), | ||
autoExternal(), | ||
internal([ | ||
`react`, | ||
`ink`, | ||
`ink-spinner` | ||
]), | ||
], | ||
external: [ | ||
`yoga-layout-prebuilt`, | ||
// Next one deserve explanation: ... it's because ink logger imports | ||
// getStore, onLogAction from higher up (../../redux). But we don't want | ||
// two copies of it - one bundled and one not, because it would result | ||
// in multiple store copies | ||
`../../redux` | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters