-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use regular Node module imports instead of absolute paths in source file #8
Comments
This package targets VanillaJS, not build tools or ESM-ish imports that mimic Node style bare import specifiers (ie no 'js' extension). In other words, this package works in browsers as-is without needing to be built/bundled/transpiled. For build tooling support, 'dist' contains a pre-built bundle that already includes the necessary imports. |
If you use the following import wc-markdown from 'wc-markdown'; It should pull in the dist bundle. |
Whenever I import the version from
That is using Webpack 4 with a config that just takes the entry file and bundles it to an output directory. There are no plugins or other transformations happening. |
Damn, that definitely isn't right. The Showdown package used here has a lot of legacy junk. This specific error is caused by a conditional require that should only be used during testing. Looks like Webpack is following the require even though it should be conditionally excluded. I'll release a patch fix. Any other notable errors? |
That was the only one popping up at the moment but I can take a look later and see if there were others that I missed. I saw your other issue for replacing Showdown with something else. Do you need help looking into other libraries? |
For now I think replacing Showdown w/ Marked will be a good choice. Showdown is like 100k vs Marked 2k. AFAIK, Marked should be compatible with PrismJS; it just might require a configuration option so the CSS classes the parser attaches to code blocks for syntax highlighting are named properly. Also, the Showdown fork I use here was supposed to be temporary until the ES module compatibility lands upstream (showdownjs/showdown#661). At this point, I doubt it'll ever land so I'd strongly prefer to kill the fork and replace it with a stable dependency. In the future I'd like to use a lib written as an ES module for even better savings. I have found a few but none seem to be stable or well-maintained enough yet. |
OK, apparently swapping the parsers was a relatively painless process. I added a 'module' field to package.json that points to the dist bundle. Using a regular default import should work w/o issue. In addition changing parsers cut the prod bundle size down from 193KB to 64KB. Not too shabby. |
While attempting to import the web component as part of the bundle with webpack, it threw a bunch of errors that didn't make sense. I then decided to just reference the source file instead of what was defined in main but that was also a problem.
Currently, the imports in the source file are absolute paths to the specified modules instead of just referencing the modules. Most build tools will handle looking in the node_modules folder if it is it not an absolute path.
ex:
should be:
The text was updated successfully, but these errors were encountered: