Comments (6)
I'm also interested in targeting node. Another difference that comes to mind is window
vs global
as the global object. Not sure if that's builtin or not
from fastpack.
Hi @zindel thanks for the reply! I think you're correct that (1) and (2) are preventing node environment from working. Not necessarily (3) though since the application might need different configuration profiles depending on the environment.
@juancampa also made a good point that global
is the "Pervasive" variable in Node, as well as __dirname
and __filename
as seen here.
from fastpack.
Hi, @mrvicadai. Thanks for the request! Unfortunately, it is impossible in the fastpack at the moment. We've been targeting browsers first. There are some builtin (not pluggable) features which prevent an easy addition of the node
target at the moment:
- Fastpack considers the browser field.
- Requiring
fs
,path
and other builtin Node.js packages leads to an error with the suggestion of the browser-friendly mocks process.env.NODE_ENV
is replaced across the codebase with the constant (development
orproduction
) as well as non-matched if/ternary branches are pruned.
If I understand the feature request correctly, for the node
target you definitely don't want (1). (2) should leave require
statements intact. What about (3)? Is it desired behaviour or it should be skipped as well? Is there anything else specific about the node
target?
from fastpack.
@juancampa @mrvicadai could you suggest a reasonably simple (but still with some dependencies) app we could use for testing?
from fastpack.
@zindel I was looking at the source tree of the parcel bundler
and found some integration test cases that might just serve as SSCCE for this:
In terms of real world example, I can think of this one as reasonably small, but very frequently used node package: https://github.com/isaacs/rimraf/blob/master/rimraf.js
from fastpack.
Also what could be interesting for (2) is that we have a way to ignore some require() to be considered. See https://arunoda.me/blog/ssr-and-server-only-modules for an example. Webpack have its IgnorePlugin for this purpose.
from fastpack.
Related Issues (20)
- Hoist imported identifiers HOT 2
- getting `Malformed unicode` error when importing png file with and without `--preprocess='file-loader'` HOT 14
- bundle/index.js has 600 permission instead of 644 HOT 3
- production mode injects an unexpected ")" HOT 2
- production mode attempts to export non-existing default, causes a silent runtime error
- [question] use ES5 for internals? HOT 1
- Provide --rewrite option for server HOT 2
- fpack failing to dynamically link libssl HOT 7
- fpack watch mode fails HOT 5
- omitDefault is not a function HOT 3
- libssl.so.1.1 error HOT 5
- Add option for bundle file name HOT 8
- Add the ability to inject environment variables into the final bundle HOT 4
- 0.7.0 and 0.8.0 npm releases HOT 5
- Yarn Plug’n’Play HOT 1
- swc support HOT 6
- Unify the terminal color output API HOT 2
- Uncaught TypeError: Cannot read property 'm' of undefined HOT 1
- ExportFinder > Cannot export twice HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastpack.