I have two file: file A.js:
export default={
name:"sample"
}
file B.svelte:
import {name} from './A';
Error: name is not export from A.js
There are two problems there:
That's now how you make the default export an object, you should remove the =.
import is not destructuring, they just have a superficial resemblance to each other. You can't destructure during an import.
I would make the export a named export:
export let name = "sample";
...which would work with your import. Changes to name by the source module will show up in the imported binding for it (imports are live bindings to the original export).
But if you don't want to do that, here's how you export an object as the default export:
export default {
name: "sample",
};
and then you have to import and destructure separately:
import obj from "./A.js";
const { name } = obj;
Note: The above is how standard JavaScript modules work according to specification. Bundlers may go beyond the spec when bundling code (for instance, may allow named import syntax when in fact you're destructuring a default exported objects), but if so, it's non-standard.