Webpack plugin that helps importing .cdc files

Overview

cadence-webpack-plugin

Webpack plugin that helps importing .cdc files and polyfills fcl dependencies

This fixes the Buffer is not defined and Module not found: Error: Can't resolve 'http' bugs

Install

npm i cadence-webpack-plugin -D

Usage

import MINT_NFT from './flow/mint-nft.cdc'

await mutate({
  cadence: MINT_NFT,
  // ...
});

Before/After

This plugin helps improve the development experience by allowing the import of Cadence code within a .cdc file directly in Javascript, instead of needing to wrap the Cadence code in a Javascript const wrapper.

Previously we may have needed to do the following:

export const GET_FUSD_BALANCE = `
  import FungibleToken from 0xFungibleToken
  import FUSD from 0xFUSD

  pub fun main(address: Address): UFix64 {
  let account = getAccount(address)

  let vaultRef = account
  .getCapability(/public/fusdBalance)
  .borrow<&FUSD.Vault{FungibleToken.Balance}>()
  ?? panic("Could not borrow Balance capability")

  return vaultRef.balance
  }
`

Importing directly into JS without wrapping the Cadence code allows us to see the syntax highlighting when modifying the Cadence code because it is in its native .cdc format.

Example:

image info

Setup with Webpack

In your webpack.config.js

const CadencePlugin = require('cadence-webpack-plugin')

module.exports = {
  // ...
  plugins: [
    new CadencePlugin(),
    // ...
  ]
}

Shortcut setup with Nullstack

In your webpack.config.js

const [server, client] = require('nullstack/webpack.config');
const { applyCadencePlugin } = require('cadence-webpack-plugin')

module.exports = applyCadencePlugin([server, client])

License

This project is released under the MIT License.

You might also like...

React Starter Kit — isomorphic web app boilerplate (Node.js, Express, GraphQL, React.js, Babel, PostCSS, Webpack, Browsersync)

React Starter Kit — isomorphic web app boilerplate (Node.js, Express, GraphQL, React.js, Babel, PostCSS, Webpack, Browsersync)

React Starter Kit — "isomorphic" web app boilerplate React Starter Kit is an opinionated boilerplate for web development built on top of Node.js, Expr

Dec 30, 2022

A complete set up of the React application with Typescript, Webpack 5, Babel v7, SSR, Code Splitting and HMR.

Getting Started with react-final-boilerplate Clone the code npm install You are good to go with React Application. Open http://localhost:3000/ and you

Dec 22, 2022

React/Express/Webpack Boilerplate

React Boilerplate The following repo contains a very basic setup git clone https://github.com/asieke/React-Express-Boilerplate.git cd React-Express-Bo

Dec 30, 2022

Single Page Application with React, React Router, PostCSS, Webpack, Docker and Docker Compose.

spa-store Single Page Application with React, React Router, PostCSS, Webpack, Docker and Docker Compose. Contributing Feedback Roadmap Releases Check

Jul 4, 2022

.properties file parser, JSON converter and Webpack loader.

properties-file .properties file parser, JSON converter and Webpack loader. Installation 💻 ⚠ in June 2022 we have released version 2 of this package

Dec 15, 2022

This a todo list project that uses webpack. In this project you will find features like adding tasks, deleting tasks, maintaining localstorage, marking tasks completed and clearing all completed tasks.

webpack-Todo list This a todo list project that uses webpack. In this project you will find features like adding tasks, deleting tasks, maintaining lo

Jun 15, 2022

📄 Create PDF files using React

📄  Create PDF files using React

React renderer for creating PDF files on the browser and server Lost? This package is used to create PDFs using React. If you wish to display existing

Jan 7, 2023

This is made for those who are learning react and are tired of doing create-react-app and having to delete those unused files

Easy React Pack (ERP) This is made for those who are learning react and are tired of doing create-react-app and having to delete those unused files. H

Jan 12, 2022

Is a collection of utils for the system, directories, deno and files informations :p

Is a collection of utils for the system, directories, deno and files informations :p

Is a collection of utils for the system, directories, deno and files informations :p

Jul 22, 2022
Owner
AE Studio
Building products to increase human agency
AE Studio
This is a simpler project than the full webpack source code, and you can understand the design ideas in webpack through it

my-webpack 这是一个简化版的webpack,旨在于理解webpack的设计原理以及webpack当中 loader和plugin的区别,运行方式。 运行步骤如下(方案一): 切换到my-webpack目录,运行npm install 切换到test目录,运行npm install 在tes

null 14 Sep 30, 2022
Webpack plugin to tree-shake and minify JSON modules

webpack-json-access-optimizer Optimize JSON modules that are referenced via accessor function. For example, i18n locale JSONs. Features Tree shaking R

hiroki osame 33 Oct 23, 2022
A plugin that lets you override the Webpack modules public path in webpage runtime.

dynamic-public-path-plugin A plugin that lets you override the Webpack modules public path in webpage runtime. plugin : webpack-runtime-public-path-pl

dxh_vip 4 Jan 25, 2022
The repository helps you learn React by building Netflix :star:

Learn React by Building Netflix. Click ⭐ if you like the project. Pull Request are highly appreciated ❤️ You can check the advance folder for more Rea

Hiep Le 181 Dec 22, 2022
This command line helps you create components, pages and even redux implementation for your react project

react-help-create This command line helps you create components, pages and even redux implementation for your react project. How to install it? To ins

Omar 27 Dec 10, 2022
This app helps you keep track of your expenses in months and years. Also, it shows a graph representing those expenses.

Expenses Tracker This app helps you keep track of your expenses in months and years. Also, it shows a graph representing those expenses. Built With Ma

Nicolae Pop 6 Aug 8, 2022
A react component helps bring Figma's Cursor Chat to your web applications in less than 3 minutes, making real-time collaboration anywhere

@yomo/react-cursor-chat ?? Introduction A react component helps bring Figma's Cursor Chat to your web applications in less than 3 minutes, making real

YoMo 84 Nov 17, 2022
A React-Fullstack platform helps to track & compare your Incomes & Expenses transactions in one place via detailed Graphical information to manage your Budget.

Budget Master Track your income and expenses in one place via detailed graphical information to manage your budget. Manage your budget and transaction

Siddharth Singh Bhadoriya 9 Nov 27, 2022
Concircle scanner mobile app is application That helps you scan your order and position and to know if there are exact or not. it's cross-platform app.

Concircle scanner mobile app ⭐ Star on GitHub — it motivates Me a lot! Concircle scanner mobile app is application That helps you scan your order and

Aymen Ouerghui 10 May 7, 2022
React-play is an opensource platform that helps you learn ReactJS faster with hands-on practice model

react-play is an opensource web app that helps you learn ReactJS faster with hands-on practice model. It is a collection of ReactJS projects that you can use to learn ReactJS.

Tapas Adhikary 580 Dec 30, 2022