babel-plugin-preval
babel-plugin-preval copied to clipboard
🐣 Pre-evaluate code at build-time
I'm migrating a legacy React TypeScript project from Webpack to Vite. I have some pretty substantial preval code. Vite uses Babel internally, so I think it should be possible to...
So I was trying to use `preval` to insert functions into my code before run time. What I thought was going to be quite trivial, turned out to be a...
When using `// @preval` at the top of the file, it's first evaluated in Node.js. This means that TypeScript has no idea what's going on. If I leave these files...
- `babel-plugin-preval` version: 5.1.0 - `node` version: 16.12.0 - `npm` (or `yarn`) version: 8.4.1 Relevant code or config ```javascript const gitHash = preval` import GitInfo from 'react-git-info/macro'; gitInfo = GitInfo();...
- `babel-plugin-preval` version: v5.0.0 - `node` version: v14.17.0 - `npm` (or `yarn`) version: npm v6.14.13 Relevant code or config ```javascript import tailwindConfig from /* preval */ '../tailwind.config'; export const extractedTailwindConfig...
Using: "webpack": "^4.46.0", "nuxt": "^2.15.8", "babel-plugin-preval": "^5.0.0", ``` const locale = 'ru' // @/langs/ru.js: // // @preval // // module.exports = require('../tools/i18n').packs.ru const langPack = require(`@/langs/${locale}.js`) // WORKS //const langPack...
- `babel-plugin-preval` version: 1.4.1 - `node` version: 8.1.3 - `npm` (or `yarn`) version: npm 5.2.0 Relevant code or config ```javascript const result = preval` const fs = require('fs'); const path...
- `babel-plugin-preval` version: 5.0.0 (preval.macro 3.0.0) - `node` version: v14.16.1 - `npm` (or `yarn`) version: 6.14.12 Relevant code or config ```javascript export const searchPosts = preval` const tool = require('../../graphql/utils');...
Continuing from #82, with more generic handling... **What**: Allows preval to parse typescript (and potentially any dialect supported by babel with some extra work) **Why**: Preval currently chokes on typescript....
**What**: Allows preval to parse typescript (and potentially any dialect supported by babel with some extra work) **Why**: Preval currently chokes on typescript. This PR serves as a *proof-of-concept* to...