Comments (3)
Is it correct to have an import declaration with an empty import clause?
Yes. It is different between importing a module or not importing it at all. The former means to keep any side effects in the dependency.
For example, if ./foo.js
has code:
// foo.js
console.log('side effect')
As a consequence the user ideally should see the log at runtime. That's why the import statement is kept.
from esbuild.
This is because you have set verbatimModuleSyntax: true
. esbuild is generating the effectively same code as TypeScript compiler itself: TypeScript Playground
from esbuild.
I wasn't aware of the fact that the TypeScript compiler also behaves like this. Thanks for pointing it out!
Having said that, is it correct to have an import declaration with an empty import clause?
What side effects could cause if esbuild dropped entirely the import declaration if only types are being imported?
I can understand that esbuild may want to output similar code as the TypeScript compiler, but right now I don't see why it's important to keep the import declaration.
Feel free to close it if this is the expected behavior.
Thanks for the answer!
from esbuild.
Related Issues (20)
- How do i get the build result using js-api during watch? HOT 4
- Why is ESBuild not including React in the bundle? HOT 2
- @aws-sdk/lib-storage File Upload is not working at [email protected] HOT 1
- Outrageous peak memory usage with binary modules
- option: single line output (escape newline whitespace) HOT 2
- With `await esbuild.stop()`, deno test still detect resource leaks HOT 1
- [WARNING] Base config file "./xxxx.json" forms cycle [tsconfig.json]
- Unused code is left when minifying
- No loader is configured for ".node" files HOT 1
- [question] Working directory CLI argument HOT 2
- i have a question , why is vite not used esbuild to bundle ,however select rollup to build HOT 3
- Unable to bundle WASM modules read by `node:fs` HOT 4
- I meet a error when using webpack bundle esbuild
- Variable assignment could not be repeated
- Plugin callback for unresolved imports HOT 10
- `oklch` in CSS custom properties is not transformed
- Specify license on the bundle analyzer for reuse
- Transforms `async: async` in objects to shorthand `async` for old platforms HOT 4
- The execution results of decorator code compiled by esbuild and compiled by tsc are inconsistent HOT 7
- Question: use esbuild watch and typescript tsc --noEmit to check types on change 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 esbuild.