Open Olli-palkkaus opened 2 years ago
Hi @Olli-palkkaus , Thanks for your suggestion. But i have no idea about import.meta.url
in snowpack.config.mjs.
Whats the output in tranforms runtime? And the path of file should be a string, else it will be ignore.
And the path of file should be a string, else it will be ignore.
Oh, you are correct. I thought I had fixed the issue with new URL("./index.js", import.meta.url)
, but it was actually completely ignored not being a string. Therefore it was applying the replace to ALL files and I mistakenly thought the filter was matching to the file that I was testing.
When I add new URL("./index.js", import.meta.url).toString()
it no longer works, so the result of this is not exactly the same as what the file id is matching in the plugin. So my suggestion does not work. At least not in Windows. At the moment, I do not have an idea how to fix this. I am now just using __SNOWPACK_ENV__ instead because I can use that to do what I need without a plugin.
I took the idea from here: https://nodejs.org/api/esm.html#esm_no_require_resolve
import.meta.url
just work in browser runtime. But in snowpack , i dont know whats is it.
And for your other suggestion, i had update README file, pls check it again.
Thanks for your suggestion
Documentation says that the file parameter needs to be a full path:
string
optional specify file path. its should be a full pathIn the new examples, mjs-files are used in the configuration and there
require.resolve
is not available. How to overcome this is not so evident: it is not so easy to find the right terms to google.Suggest adding:
Also, it may be worth mentioning in which files the content is replaced:
static: true
, that didn't work// MARKER //
=>doSomeStuff()
and this does not work because comments are removed by Snowpack all togetherAll of the restrictions are understandable, but it would be good to add them in the docs.
Thanks for the plugin though! Once I understood what it does, it did what I needed.