swc-project / swc-loader

Moved to https://github.com/swc-project/pkgs
MIT License
394 stars 29 forks source link

Import unnamed resources #6

Closed duncanbeevers closed 5 years ago

duncanbeevers commented 5 years ago

@babel/helper-module-imports permits import statements with no identifier to establish dependencies between files without exposing a javascript expression for that import.

https://babeljs.io/docs/en/babel-helper-module-imports

Common usage looks like

import 'bootstrap';

swc / swc-loader doesn't recognize this form of import statement, and throws.

Module parse failed: Unexpected token

Expected behavior

A dependency should be established between the parent and referenced file; no javascript expression representing the imported resource should be generated.

kdy1 commented 5 years ago

@duncanbeevers I think correct syntax is import 'bootstrap';. Isn't it? Babel's documentation also say import 'bootstrap'; is correct.

duncanbeevers commented 5 years ago

Yes, that's right. I've corrected the description to reflect this. The error described is still valid.

kdy1 commented 5 years ago

Codegen of side-effect imports was wrong. import 'sideeffect' is converted to import from 'sideeffect'; I'll fix it soon