Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update package.json to successfully resolve forked packages #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
node_modules
lerna-debug.log
lerna-debug.log*
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.DS_Store
85 changes: 85 additions & 0 deletions HACK.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@



---
## 2018-04-19

### missing fontAwesome icons

problem: demo assigns `grip-horizontal` to Grid toolbar button. It doesn't show up b/c it's from fontawesome v5.

solution:
- use different icon (`th-large`) from fontawesome v4
- switch cdn to use.fontawesom.com for v5. but eww they are getting crazy commercial.

in `node_modules/@axe312/easymde/src/js/easymde.js`

```
/**
* Interface of EasyMDE.
*/
function EasyMDE(options) {
// Handle options parameter
options = options || {};

// Used later to refer to it"s parent
options.parent = this;

// Check if Font Awesome needs to be auto downloaded
var autoDownloadFA = true;

var fontAwesomeURL = 'https://use.fontawesome.com/releases/v5.8.1/css/all.css'
var fontAwesomeURLpattern = '//use.fontawesome.com/releases/'

if (options.autoDownloadFontAwesome === false) {
autoDownloadFA = false;
}

if (options.autoDownloadFontAwesome !== true) {
var styleSheets = document.styleSheets;
for (var i = 0; i < styleSheets.length; i++) {
if (!styleSheets[i].href)
continue;

// if (styleSheets[i].href.indexOf('//maxcdn.bootstrapcdn.com/font-awesome/') > -1) {
if (styleSheets[i].href.indexOf(fontAwesomeURLpattern) > -1) {
autoDownloadFA = false;
}
}
}

if (autoDownloadFA) {
var link = document.createElement('link');
link.rel = 'stylesheet';
// link.href = 'https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css';
link.href = fontAwesomeURL;
document.getElementsByTagName('head')[0].appendChild(link);
}

```

### yarn can't resolve forked packages that haven't been published

https://github.com/axe312ger/mdx-live-editor/pull/2

problem: `mdx-live-editor` requires forks of npm packages that are not published on npm or yarn registries. Perhaps you have them `yarn link`ed on your dev box?

```bash
# master was at f3da3ff
$ git clone mdx-live-editor
$ cd mdx-live-editor
$ yarn
yarn install v1.15.2
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@axe312/babel-plugin-inline-import/-/babel-plugin-inline-import-4.0.0.tgz: Request failed \"404 Not Found\"".
# same thing happens w/ '@axe312/easymde'
```

The two commits show alternative approaches to fixing the error:
- use forked package [github url in package.json](https://yarnpkg.com/en/docs/cli/add#toc-adding-dependencies): this fetches the up-to-date fork source code from your repos
- use [yarn alias](https://yarnpkg.com/en/docs/cli/add#toc-yarn-add-alias) to to rename original packages to name of forked packages: this fetches the original packages from npm/yarn registry, but allows the `mdx-live-editor` source code to refer to them in imports as if they were the forked version. Not good approach if you plan on modifying your forks.

either way, both solutions allow `git clone`ing then `yarn` installing to work successfully while retaining the alternate names of the forked packages (i.e. `import EasyMDE from '@axe312/easymde'`). If you ever publish your forks, you would just need to change the `package.json`s in this repo.

I really like this project - thanks for publishing it! I am working on something kinda similar (and also saw the `[blocks/blocks](https://github.com/blocks/blocks)` project announcement, so I will see you around and perhaps even have some contributions someday.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# forked - now w/ [rbx](https://dfee.github.io/rbx/) components

screenshot

---

# MDX Live Editor

> Extensible mdx editor to edit mdx and preview live in your browser.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"publish": "lerna version --no-push --conventional-commits && lerna publish from-git"
},
"devDependencies": {
"lerna": "^3.13.3"
"lerna": "^3.13.3",
"parcel-bundler": "^1.12.3"
},
"workspaces": [
"packages/*"
Expand Down
4 changes: 2 additions & 2 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"private": true,
"homepage": "https://axe312ger.github.io/mdx-live-editor/",
"dependencies": {
"@axe312/easymde": "^2.7.1",
"@axe312/easymde@npm:easymde": "^2.6.1-157.0",
"@mdx-live/editor": "^0.0.5",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"styled-components": "^4.2.0"
},
"devDependencies": {
"@axe312/babel-plugin-inline-import": "^4.0.0",
"@axe312/babel-plugin-inline-import@npm:babel-plugin-inline-import": "^3.0.0",
"@babel/core": "^7.4.3",
"@babel/plugin-proposal-class-properties": "^7.4.0",
"gh-pages": "^2.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/demo/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const components = [
component: Grid,
title: 'Grid',
description: 'Display content next to each other',
icon: 'grip-horizontal',
icon: 'th-large',
demo: `<Grid>
<img src="https://source.unsplash.com/weekly?water" alt="" />
<img src="https://source.unsplash.com/weekly?nature" alt="" />
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/axe312ger/mdx-live-editor#readme",
"dependencies": {
"@axe312/easymde": "^2.7.1",
"@axe312/easymde@npm:easymde": "^2.6.1-157.0",
"@mdx-js/runtime": "^0.20.3",
"react": "^16.8.6",
"react-dom": "^16.8.6"
Expand Down
Loading