UPDATE: The information in this question is no longer current. As of 12.8.2022, it is recommended to use the svelte-kit package
available at .
I developed a library (https://github.com/TeemuKoivisto/svelte-tree-view) that I imported as a Svelte component in another project. While it worked fine when linked locally using yarn link svelte-tree-view
, I encountered a strange error when using the npm downloaded version from node_modules:
[!] (plugin svelte) ValidationError: The $ prefix is reserved, and cannot be used for variable and import names
../node_modules/svelte-tree-view/src/TreeView.svelte
77: rootElementStore.set(rootElement);
78: });
79: var $$$$$$$$ = null;
^
80: var $$vars$$ = [$$props, rootElement, $treeStore, treeStore, TreeNode_svelte_1.default];</script>
This error was challenging to troubleshoot due to limited online resources. However, I managed to find a simple solution and decided to share it here to assist others facing similar issues. Below are the key libraries relevant to resolving this problem:
"rollup": "^2.56.3",
"rollup-plugin-svelte": "^7.1.0",
"rollup-plugin-ts": "^1.4.2",
"svelte": "^3.42.6",
"svelte-preprocess": "^4.9.4",
"tslib": "^2.3.1",
"typescript": "^4.4.3"