Comments (25)
I upgraded node v9.2.0 and solved it.
from parcel.
my node version is v6, this issue was be fixed after upgrade to v8
from parcel.
Looking forward to this fix pending (#253).
To the project maintainers:
Having recently heard about Parcel and it's zero configuration feature, I was eager to try it out on a new project, but quickly found that the "Getting Started" example just fails, which needless to say is not a good reflection upon this library. My suggestion (until this issue is fixed) would be for you to list the current limitation (requires nodeJS v > 6) on your README file and website.
Appreciate the work that has gone into this library and for the introduction of a zero config bundler. I will revisit this again in the future...
from parcel.
In strict or sloppy mode, you can always use Function(‘return this’)()
in every engine except CSP-enabled browsers (however, for those, you can use window || self
.
from parcel.
i try it, since v7.0.0 to v7.9.0, it cannot run, but when I use v8.0.0, it done !, so, I guess parcel need Node version is greater than or equal to v8.0.0
from parcel.
Still getting the same issue.
Node version : 9.5.0
Parcel version : 1.5.1
Just have a button in my html page which on clicking calls the clickHandler function in the js file. Get an error saying 'ReferenceError: clickHandler is not defined'. I could find the function in the built js file under dist.
Note: have configured to use babel. But still.. 😞
from parcel.
@phobal But what results to the problem, I would like to konw the explaniation. It's all konwn that require
is supported at the node @v6.x.x
from parcel.
Was on node6, upgrading to node8 let me run this example without issues (and the most basic one advertised on the 'getting started' page)
node8 is obviously required; so is a minimal .babelrc setup
Not a dropin webpack replacement at all :/, was too good to be true. Using the same package.json, I'm now getting hellish bugs when trying replace a webpack conf within an es6 app (...spreads
breaks, among other things), end up sad not being able to investigate further at the moment
from parcel.
We're relying on non-strict mode. Some tool (most likely Babel is adding in the "use strict"
.
We should probably update the prelude.js file to find the correct global to attach to.
@ljharb What's the best way to get global
(whether it be window/self/global/this
) today?
from parcel.
Just chiming in; I was getting a different error #31, but after that issue was fixed I'm now getting this error with node6.
from parcel.
I was looking into the issue but I think even fixing the use strict problem we will have problems with babel transforming require = (function (modules, cache, entry) { ... })
to require = function (modules, cache, entry) { ... };
when the project is built.
So in node 7 and further, when the script is compiled by parcel and the browser loads, we have correctly require = (function (modules, cache, entry) { ... })([modules])
which is a iife. Because it uses the files under src/* which are not compiled it uses the original file. But in node 6 and before it generates require = function (modules, cache, entry) { ... };([modules])
. Which makes the page render nothing.
Not sure how to fix that. Maybe we could make babel ignore this specific file and just copy it to lib?
Also is it a bad idea to just not support node 6? I think people using parcel are mostly testing it or creating new stuff, in this case they can at least use a more up to date node version.
from parcel.
I just ended up upgrading to Node 8x series since it is on LTS
from parcel.
just upgrade the node version to v8.9.3,can fix this problem.
from parcel.
@xswei me,too! But do you know why?
from parcel.
@wqcstrong right. node 6.x was supported, however, it run in node V8 environment, in browser cannot support require
from parcel.
@wqcstrong @phobal 老铁 parcel只支持8以上版本,具体原因知道吗?
from parcel.
Also bumped into this on Node 6.11. The first few lines of the generated file follow. Note the implicit global assignment in require = function(...)
, which is the reason the error is thrown in strict mode. Manually deleting the use strict
line, or using var require = function...
prevents the error from being thrown, but the generated file actually never calls the require
function.
"use strict";
// modules are defined as an array
// [ module function, map of requires ]
//
// map of requires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles
require = function (_require) {
Edit: the reason require
doesn't get called is an extra semicolon after the definition of function(modules, cache, entry) { ... });(...)
. That semicolon means the function expression isn't immediately invoked.
from parcel.
@xswei 上面的大佬大概说了导致报错的原因了 @guilhermeasg :1、删除严格模式;2、var
声明变量
from parcel.
@guilhermeasg Hey buddy,I have tried to find the semicolon you said in the complied file, but I did not find it after reading what you said.
from parcel.
@wqcstrong thanks for following up. I uploaded the bundled file to a gist for direct examination. This file has been generated, as in the example in the main page, simply by running parcel index.html
on the provided file.
Note that line 11 is an implicit global definition, which is forbidden in strict mode (L1), hence the error. Furthermore, take a look at L80:
});({7:[function(require,module,exports) {
The expression after the semicolon is supposed to be the argument to the previously defined function (making it an IIFE), but the semicolon breaks it into an object declaration with no side effects.
from parcel.
what wrong to write
var require = function (_require) {
instead of just
require = function (_require) {
?
It make it global just fine
from parcel.
@perymimon see my comment for the reason
from parcel.
Just as an update:
I'm getting this issue with parcel bundler version 1.4.1 & node version v9.4.0.
Both fresh installs today.
from parcel.
@mike-rotate Can you try it again using the new Parcel version?
from parcel.
Node 6 support was just merged in #789. Should be released in 1.6.0 this week!
from parcel.
Related Issues (20)
- react-refresh dependency is locked at v0.9.0 HOT 6
- @parcel/transformer-css: Unknown at rule: @apply
- @parcel/optimizer-css rejects CSS namespaces on the ground they should appear earlier in the CSS HOT 2
- Async import doesn't work as expected when passing a dynamic path
- [RFC] Moving to trunk based development and introducing feature flags HOT 2
- Cannot import css from mantine-datatable HOT 3
- postcss fails: @parcel/transformer-postcss: Cannot read properties of undefined HOT 1
- @parcel/register throws error `parcel[_core(...).INTERNAL_RESOLVE] is not a function`
- Parcel build fails on Chrome < 86 due to dynamic import and chunking issues HOT 1
- Unable to make `typeof process !== 'undefined'` false
- Parcel Macro in the REPL HOT 1
- segfault on parcel >= 2.10.0
- `parcel/config-webextension` can build extensions incompatible with Firefox's Add-Ons Store HOT 1
- Type-introspection with macros
- Vue 3 defineProps fail with imported types
- TypeScript syntax does not work in Vue templates
- I can't modified the HTML, cause every single time parcel brokes HOT 2
- Parcel build/watch silently fails HOT 1
- @parcel/transformer-css: Unexpected token Semicolon HOT 2
- Default Cache folder location is on root instead of workspace folder HOT 2
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 parcel.