survivejs / react-component-boilerplate Goto Github PK
View Code? Open in Web Editor NEWBoilerplate for React.js components (MIT)
Home Page: https://survivejs.github.io/react-component-boilerplate/
License: MIT License
Boilerplate for React.js components (MIT)
Home Page: https://survivejs.github.io/react-component-boilerplate/
License: MIT License
Looks a little nicer that way.
Hi! I really like this project. I'm attempting to use it in an educational workshop tomorrow but I'm stuck.
I'm running I keep running into an issue where my dist-modules are attempting to require .jsx
files, but the compiled files in dist-modules has .js
extensions resulting in an error.
This is strange to me because the docs compile and run fine, and everything else is great. But when I install the package into another project such as create-react-app it results in the aforementioned errors with JS/JSX
Here are some screenshots
And here is a link to my test repo https://github.com/richattack/testjam
This is my first attempt at making an external component library. I've been debugging this issue for weeks not sure what the problem but I believe it to be a webpack or babel related issue.
Thanks!
Rich
This is the output followed by no changes in the gh-pages
branch and no directory called gh-pages
created
➜ react-selection-popover master ✗ npm run gh-pages
> [email protected] gh-pages /react-selection-popover
> webpack
reading file /react-selection-popover/README.md
Why you put post_install.js script in lib folder if .npmignore including those? It make npm install error on postinstall command.
It would be nice to have storybook added to the boilerplate so to check components as being developed. I particularly don't use github pages but I think it only allows for a single repo to be deployed, so anyone with multiple projects would have trouble dealing with it.
I am a Windows dev (please don't shun me) and running scripts on package.jsn
that have the setting BABEL_ENV=xxx
causes an error. Also happens with rimraf
, which I can overcome with replacing it with del-cli
package.
Please consider making the scripts Windows friendly ;)
Running npm install
on Windows ends with an error because rm
does not exist.
This should be the same as in the book. Simpler, less code.
Related to npm/npm#7906 .
Still missing some bit here.
npm should pick it up, though. No need to version the data.
ESLint can replace it altogether. One less dependency.
I get these errors when running npm run lint
:
~/dev/react-component-boilerplate $ npm run lint
> [email protected] lint /Users/saschwarz/dev/react-component-boilerplate
> eslint . --ext .js --ext .jsx
The react/jsx-quotes rule is deprecated. Please use the jsx-quotes rule instead.
/Users/saschwarz/dev/react-component-boilerplate/demo/index.js
1:1 error Strict mode is not permitted strict
/Users/saschwarz/dev/react-component-boilerplate/lib/deploy_gh_pages.js
1:1 error Strict mode is not permitted strict
/Users/saschwarz/dev/react-component-boilerplate/src/index.js
1:1 error Strict mode is not permitted strict
/Users/saschwarz/dev/react-component-boilerplate/webpack.config.babel.js
1:1 error Strict mode is not permitted strict
✖ 4 problems (4 errors, 0 warnings)
Did you want to update the .eslintrc
to specify "strict": 0
?
I'm not certain how to resolve: The react/jsx-quotes rule is deprecated. Please use the jsx-quotes rule instead.
I couldn't find where that is specified in the branch and jsx-quotes
is already specified in the .eslintrc
.
Hello, I've tried everything, now I'm here begging for help.
I can't seem to add support for es7 class properties using this boilerplate, I'm using this:
"presets": [
"react",
"es2015",
"stage-0"
],
"plugins": [
"transform-runtime",
"transform-class-properties"
],
and I've tried every order of those I can imagine. Any ideas?
I think it would be beneficial to update Babel to 7.x version - especially for <>
tag support (React.Fragment
) and keeping dependencies always up to date.
jest --coverage
option.
Is it possible to build components with this boilerplate that support server side rending? I see this error when I import my component:
...\dist\manifest.js:152
/******/ ([]);
^
ReferenceError: window is not defined
Keep ./dist
out of the package, https://docs.npmjs.com/misc/developers#keeping-files-out-of-your-package, https://stackoverflow.com/questions/25124844/should-i-npmignore-my-tests .
This works far better.
Now npm version
is a bit nasty. You will have to generate dist manually to get it included in a version. It probably would be better to implement a custom script for this purpose and do something like npm run version
.
Related to npm/npm#7906.
https://github.com/ColCh/jest-webpack
Ideally it would be possible to run Jest tests over Webpack watcher.
By the way, npm install fails in the boilerplate (for windows)
E:\Repositories of Code\react-component-boilerplate\node_modules\jest-cli\node_modules\jsdom\node_modules\contextify>if not defined npm_config_node_gyp (node "C:\Program
Files\nodejs\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (rebuild)
gyp ERR! configure error
This should just replace project name, author etc. based on given input.
After starting I recieve the following error:
Error: spawn catalog.js-start ENOENT
at exports._errnoException (util.js:1026:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:182:32)
at onErrorNT (internal/child_process.js:348:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:592:11)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: catalog start docs
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.
If App
changes, that breaks isomorphism (different back-end/front-end). Dev mode might need code path of its own and the requirement probably needs to be relaxed there.
it seems to be missing a package (probably due to dependency changes over time). Need to add
"loader-utils": "^0.2.16",
to your package.json
"user": "survivejs",
to your package.json too
Commands npm run dist:modules and npm run dist are successful in my component repo,
When I do a yarn add file:'../path' and add my component to my react project
and run the project it fails during compilation and displays the error You may need an appropriate loader to handle this file type
It's failing to compile JSX in my component file.
I imported my component into the Demo.jsx
file as import SVGPathPlayer from '../src/svgplayer.jsx';
My component, in turn, imports it's styling via a Sass scss file: import './svgplayer.scss';
and imports a 3rd party lib (snap.svg) which requires a custom loader. I've added the loaders to the appropriate build targets.
I get this traceback when running npm run dist
:
> webpack
/Users/saschwarz/dev/react-svgpathplayer/node_modules/babel-core/lib/transformation/file/index.js:671
throw err;
^
SyntaxError: /Users/saschwarz/dev/react-svgpathplayer/src/svgplayer.scss: Unexpected token (1:0)
> 1 | .svg-player {
| ^
2 | border: 1px solid #d3d3d3;
3 | .buttons {
4 | border-top: 1px solid #d3d3d3;
After some dividing/conquering of the webpack.config.babel.js
file I found the problem is caused by:
import App from './demo/App.jsx';
which pulls in Demo.jsx
which then brings in my component and the unsupported files.
So for now I've disabled that import, and consequently the demo functionality, and everything now compiles/runs correctly. It would be nice to re-enable the demo feature; but I'm not sure what the best solution would be.
For my purposes using the dist build of the component and manually inserting the script tags for the externals into a plain HTML file to create a demo is probably easier than the custom build step with templated insertion of the extracted bundles. I also like the idea that only one build of the component exists and it is used everywhere so I won't ever have to debug different build permutations; but I'm still new to webpack so that solution is also easiest for me to grok...
Another solution would be to not import App
into webpack.config.babel.js
and find another way to supply the template with the App
component.
The last solution I can think of is to find another way to import my component into the Demo.jsx
.
I'd greatly appreciate your input; I'm wondering if I'm not using the demo feature of this boilerplate as you intended.
First off, thank you for creating such a useful template project. It is exactly what I was looking for (and had begun to painfully create for myself).
I'm having trouble actually running tests though. Steps to reproduce:
npm i
to install dependenciestests/boilerplate_test.js
and uncomment the 3rd line (or add any import statement):import React from 'react';
npm test
or npm run tdd
The following error occurs:
$ npm run test
> [email protected] test /Users/brianvaughn/Documents/git/react-component-boilerplate
> karma start
Hash: 8344a6c0a9b3c44a5636
Version: webpack 1.12.2
Time: 18ms
ERROR in ./tests/boilerplate_test.js
Module parse failed: /Users/brianvaughn/Documents/git/react-component-boilerplate/tests/boilerplate_test.js Line 3: Unexpected token
You may need an appropriate loader to handle this file type.
| 'use strict';
|
| import React from 'react';
| // import {
| // renderIntoDocument,
I downloaded this boilerplate and modified a couple thing (removed the renderJSX from the webpack config, render the component directly in the body, etc.). And now I'm trying tp run npm run dist
and i get an error.
ERROR in ./demo/App.jsx
Module parse failed: /Users/rparent/Documents/CTSProjects/cem/modules/boilerplate/demo/App.jsx Line 2: Unexpected token
You may need an appropriate loader to handle this file type.
|
| import React from 'react';
| import Fork from 'react-ghfork';
| import pkgInfo from '../package.json';
@ ./src/index.js 3:13-39
And this is the content of the App.jsx file.
import React from 'react';
import Fork from 'react-ghfork';
import pkgInfo from '../package.json';
export default class App extends React.Component {
render() {
return (
<div>
<p>This is some text</p>
</div>
);
}
}
I'm not familiar with webpack and npm scripts yet so this might a really small thing somewhere that I forgot.
I can provide more code if you want.
Thanks 😃
Maintenance-wise it would be a good idea to consume the configuration from a project such as https://github.com/insin/nwb . Now the problem is that it becomes quite painful to manage multiple projects that are based on the boilerplate.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.