@@ -94,8 +94,6 @@ See more below.
9494- [ Use with ` babel-plugin-macros ` ] ( #use-with-babel-plugin-macros )
9595- [ Examples] ( #examples )
9696- [ Notes] ( #notes )
97- - [ Limitations] ( #limitations )
98- - [ Code transpilation] ( #code-transpilation )
9997- [ FAQ] ( #faq )
10098 - [ How is this different from prepack?] ( #how-is-this-different-from-prepack )
10199 - [ How is this different from webpack loaders?] ( #how-is-this-different-from-webpack-loaders )
@@ -122,9 +120,8 @@ Important notes:
122120
1231211 . All code run by ` preval ` is _ not_ run in a sandboxed environment
1241222 . All code _ must_ run synchronously.
125- 3 . The code string that preval evaluates will be transpiled, however, only that
126- code string will be prevaled. Learn more about this in the
127- [ limitations] ( #limitations ) section below.
123+ 3 . Code that is run by preval is not transpiled so it must run natively in the
124+ version of node you're running. (cannot use es modules).
128125
129126> You may like to watch
130127> [ this YouTube video] ( https://www.youtube.com/watch?v=1queadQ0048&list=PLV5CVI1eNcJgCrPH_e6d57KRUTiDZgs0u )
@@ -339,77 +336,13 @@ Ok:
339336}
340337```
341338
342- ## Limitations
343-
344- ### Code transpilation
345-
346- It's recommended that code you want to preval be written in a way that works in
347- the version of Node that you're running. That said, some code will be
348- transpiled. If you for some strange reason _ really_ want to write your preval
349- code in a way that requires it to be transpiled, then expand here:
350-
351- <details >
352- <summary >Expand (beware)</summary >
353-
354- Here are a few examples of what will and wont be transpiled by preval:
355-
356- > This is assuming that you've configured babel to support ESModule syntax but
357- > you're using a node version which does not support ESModules natively.
358-
359- ``` javascript
360- // a.js // this file can use ESModules. Regular babel handles that.
361- import value from /* preval */ ' ./b'
362-
363- // b.js // this file can use ESModules. preval handles that.
364- import c from ' ./c'
365- export default c
366-
367- // c.js // this file cannot have ESModules in it.
368- // Neither preval nor babel will transpile this file's contents
369- module .exports = ' c'
370- ```
371-
372- ``` javascript
373- // this file can use ESModules
374- var x = preval`
375- // this string can use ESModules
376- import b from 'b.js'
377- // however b.js and it's dependents cannot
378- `
379- ```
380-
381- ``` javascript
382- // this file can use ESModules
383- // and b.js will be transpiled and evaluated
384- // by preval so it can use ESModules too
385- // but if b.js has dependencies then it cannot.
386- var x = preval .require (' ./b.js' )
387- ```
388-
389- It's also notable that you can use preval in preval:
390-
391- ``` javascript
392- // this file can use ESModules
393- var x = preval`
394- // this string can use ESModules
395- import b from /* preval */ 'b.js'
396- // b can use ESModules (but not it's dependencies).
397- `
398- ```
399-
400- Again, this is admittedly pretty confusing, so it's strongly recommended that
401- any files you preval are written in a way that they work in node without needing
402- transpilation.
403-
404- </details >
405-
406339## FAQ
407340
408341### How is this different from prepack?
409342
410- [ ` prepack ` ] [ prepack ] is intended to be run on your final bundle after you've run your
411- webpack/etc magic on it. It does a TON of stuff, but the idea is that your code
412- should work with or without prepack.
343+ [ ` prepack ` ] [ prepack ] is intended to be run on your final bundle after you've run
344+ your webpack/etc magic on it. It does a TON of stuff, but the idea is that your
345+ code should work with or without prepack.
413346
414347` babel-plugin-preval ` is intended to let you write code that would _ not_ work
415348otherwise. Doing things like reading something from the file system are not
@@ -420,14 +353,15 @@ possible in the browser (or with prepack), but `preval` enables you to do this.
420353This plugin was inspired by webpack's [ val-loader] [ val-loader ] . The benefit of
421354using this over that loader (or any other loader) is that it integrates with
422355your existing babel pipeline. This is especially useful for the server where
423- you're probably not bundling your code with [ ` webpack ` ] [ webpack ] , but you may be using
424- babel. (If you're not using either, configuring babel for this would be easier
425- than configuring webpack for ` val-loader ` ).
356+ you're probably not bundling your code with [ ` webpack ` ] [ webpack ] , but you may be
357+ using babel. (If you're not using either, configuring babel for this would be
358+ easier than configuring webpack for ` val-loader ` ).
426359
427360In addition, you can implement pretty much any webpack loader using
428361` babel-plugin-preval ` .
429362
430- If you want to learn more, check ` webpack ` documentations about [ ` loaders ` ] [ webpack-loaders ] .
363+ If you want to learn more, check ` webpack ` documentations about
364+ [ ` loaders ` ] [ webpack-loaders ] .
431365
432366## Inspiration
433367
0 commit comments