GithubHelp home page GithubHelp logo

gatsby-plugin-preval's Introduction

gatsby-plugin-preval

A Gatsby plugin for pre-evaluating code at build-time using babel-plugin-preval.

Install

npm install --save gatsby-plugin-preval babel-plugin-preval

How to use

Edit gatsby-config.js:

module.exports = {
  plugins: ['gatsby-plugin-preval'],
};

For examples of usage, please see the readme of babel-plugin-preval.

gatsby-plugin-preval's People

Contributors

kripod avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

gatsby-plugin-preval's Issues

Import comments and preval.require don't work

Reproduction

import { short } from /* preval */ 'git-rev-sync';

Or

const { short } = preval.require('git-rev-sync');

Console output

i 「wdm」: Compiling...
 ERROR  Failed to compile with 1 errors                                                                         10:10:12
 
 error  in ./src/components/Layout.jsx
 
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module 'D:\Development\moc-ui\src\components\git-rev-sync'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    at Function.require.resolve (D:\Development\moc-ui\node_modules\v8-compile-cache\v8-compile-cache.js:162:23)
    at PluginPass.CallExpression (D:\Development\moc-ui\node_modules\babel-plugin-preval\dist\index.js:126:44)
    at newFn (D:\Development\moc-ui\node_modules\@babel\traverse\lib\visitors.js:193:21)
    at NodePath._call (D:\Development\moc-ui\node_modules\@babel\traverse\lib\path\context.js:53:20)
    at NodePath.call (D:\Development\moc-ui\node_modules\@babel\traverse\lib\path\context.js:40:17)
    at NodePath.visit (D:\Development\moc-ui\node_modules\@babel\traverse\lib\path\context.js:88:12)
    at TraversalContext.visitQueue (D:\Development\moc-ui\node_modules\@babel\traverse\lib\context.js:118:16)
    at TraversalContext.visitSingle (D:\Development\moc-ui\node_modules\@babel\traverse\lib\context.js:90:19)
    at TraversalContext.visit (D:\Development\moc-ui\node_modules\@babel\traverse\lib\context.js:146:19)
    at Function.traverse.node (D:\Development\moc-ui\node_modules\@babel\traverse\lib\index.js:94:17)
    at NodePath.visit (D:\Development\moc-ui\node_modules\@babel\traverse\lib\path\context.js:95:18)
    at TraversalContext.visitQueue (D:\Development\moc-ui\node_modules\@babel\traverse\lib\context.js:118:16)
    at TraversalContext.visitMultiple (D:\Development\moc-ui\node_modules\@babel\traverse\lib\context.js:85:17)
    at TraversalContext.visit (D:\Development\moc-ui\node_modules\@babel\traverse\lib\context.js:144:19)
    at Function.traverse.node (D:\Development\moc-ui\node_modules\@babel\traverse\lib\index.js:94:17)
 
 @ ./src/pages/404.jsx 12:0-42 16:29-35
 @ ./.cache/sync-requires.js
 @ ./.cache/root.js
 @ ./.cache/app.js
 @ multi ./node_modules/react-hot-loader/patch.js (webpack)-hot-middleware/client.js?path=http://localhost:8000/__webpack_hmr&reload=true&overlay=false D://Development//moc-ui//.cache//app
 
× 「wdm」:
ERROR in ./src/components/Layout.jsx
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module 'D:\Development\moc-ui\src\components\git-rev-sync'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    at Function.require.resolve (D:\Development\moc-ui\node_modules\v8-compile-cache\v8-compile-cache.js:162:23)
    at PluginPass.CallExpression (D:\Development\moc-ui\node_modules\babel-plugin-preval\dist\index.js:126:44)
    at newFn (D:\Development\moc-ui\node_modules\@babel\traverse\lib\visitors.js:193:21)
    at NodePath._call (D:\Development\moc-ui\node_modules\@babel\traverse\lib\path\context.js:53:20)
    at NodePath.call (D:\Development\moc-ui\node_modules\@babel\traverse\lib\path\context.js:40:17)
    at NodePath.visit (D:\Development\moc-ui\node_modules\@babel\traverse\lib\path\context.js:88:12)
    at TraversalContext.visitQueue (D:\Development\moc-ui\node_modules\@babel\traverse\lib\context.js:118:16)
    at TraversalContext.visitSingle (D:\Development\moc-ui\node_modules\@babel\traverse\lib\context.js:90:19)
    at TraversalContext.visit (D:\Development\moc-ui\node_modules\@babel\traverse\lib\context.js:146:19)
    at Function.traverse.node (D:\Development\moc-ui\node_modules\@babel\traverse\lib\index.js:94:17)
    at NodePath.visit (D:\Development\moc-ui\node_modules\@babel\traverse\lib\path\context.js:95:18)
    at TraversalContext.visitQueue (D:\Development\moc-ui\node_modules\@babel\traverse\lib\context.js:118:16)
    at TraversalContext.visitMultiple (D:\Development\moc-ui\node_modules\@babel\traverse\lib\context.js:85:17)
    at TraversalContext.visit (D:\Development\moc-ui\node_modules\@babel\traverse\lib\context.js:144:19)
    at Function.traverse.node (D:\Development\moc-ui\node_modules\@babel\traverse\lib\index.js:94:17)
 @ ./src/pages/404.jsx 12:0-42 16:29-35
 @ ./.cache/sync-requires.js
 @ ./.cache/root.js
 @ ./.cache/app.js
 @ multi ./node_modules/react-hot-loader/patch.js (webpack)-hot-middleware/client.js?path=http://localhost:8000/__webpack_hmr&reload=true&overlay=false D://Development//moc-ui//.cache//app
i 「wdm」: Failed to compile.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.