Compile JS without requires
See original GitHub issueI’m using 2.0.0-alpha.3.2
and I wonder how can I build JS file without require()
calls in it?
If I call parcel build index.html
then I get it right. But due to my current project structure I need to have parcel build app.js
(in order to have constant minified JS file name). But in this case, it compiles unusable for browser execution (has require()
calls inside).
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (4 by maintainers)
Top Results From Across the Web
How to compile require statements? - javascript - Stack Overflow
Transpiling your code is not enough to make it work in a browser. You will need a build system like webpack to bundle...
Read more >Should You Compile Your JavaScript Code? - Bits and Pieces
That is not the same as compiling JavaScript. ... But then again, it might not be required for you to write ES6-compatible code...
Read more >JavaScript needs the compile step (on install) - Gleb Bahmutov
We all pretend that JavaScript is unique because it does not require a build or compile step on the client. Yet, this is...
Read more >Requiring modules in Node.js: Everything you need to know
If you want to only resolve the module and not execute it, you can use the require.resolve function. This behaves exactly the same...
Read more >RequireJS in Node
Yes! The Node adapter for RequireJS, called r.js, will use Node's implementation of require and Node's search paths if the module is not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Having the same issue here. The moment I add
targets
to package.json it starts compiling to commonjs require() calls even for the browsr target. I have none of main, default, or other extra fields in package.json..babelrc:
I’m also seeing a bunch of
@parcel/packager-js: Cannot read property 'constantViolations'
andError: Got unexpected undefined
depending on how I setup these, quite hard to pinpoint what’s going on.This solution is useless if you guys want to have external modules (like external jQuery or Bootstrap) and browser builds simultaneously. As described in https://github.com/parcel-bundler/parcel/pull/4072#issuecomment-627428171
Classic Parcel of version 1 solves it with
parcel-plugin-externals
plugin.