mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-18 07:21:24 +00:00
Implement the local JS snippets RFC
This commit is an implementation of [RFC 6] which enables crates to inline local JS snippets into the final output artifact of `wasm-bindgen`. This is accompanied with a few minor breaking changes which are intended to be relatively minor in practice: * The `module` attribute disallows paths starting with `./` and `../`. It requires paths starting with `/` to actually exist on the filesystem. * The `--browser` flag no longer emits bundler-compatible code, but rather emits an ES module that can be natively loaded into a browser. Otherwise be sure to check out [the RFC][RFC 6] for more details, and otherwise this should implement at least the MVP version of the RFC! Notably at this time JS snippets with `--nodejs` or `--no-modules` are not supported and will unconditionally generate an error. [RFC 6]: https://github.com/rustwasm/rfcs/pull/6 Closes #1311
This commit is contained in:
@ -272,7 +272,7 @@ impl<'src> FirstPassRecord<'src> {
|
||||
) {
|
||||
let variants = &enum_.values.body.list;
|
||||
program.imports.push(backend::ast::Import {
|
||||
module: None,
|
||||
module: backend::ast::ImportModule::None,
|
||||
js_namespace: None,
|
||||
kind: backend::ast::ImportKind::Enum(backend::ast::ImportEnum {
|
||||
vis: public(),
|
||||
@ -463,7 +463,7 @@ impl<'src> FirstPassRecord<'src> {
|
||||
self.append_required_features_doc(&import_function, &mut doc, extra);
|
||||
import_function.doc_comment = doc;
|
||||
module.imports.push(backend::ast::Import {
|
||||
module: None,
|
||||
module: backend::ast::ImportModule::None,
|
||||
js_namespace: Some(raw_ident(self_name)),
|
||||
kind: backend::ast::ImportKind::Function(import_function),
|
||||
});
|
||||
@ -539,7 +539,7 @@ impl<'src> FirstPassRecord<'src> {
|
||||
import_type.doc_comment = doc_comment;
|
||||
|
||||
program.imports.push(backend::ast::Import {
|
||||
module: None,
|
||||
module: backend::ast::ImportModule::None,
|
||||
js_namespace: None,
|
||||
kind: backend::ast::ImportKind::Type(import_type),
|
||||
});
|
||||
|
Reference in New Issue
Block a user