You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed the instructions to build my project with npm run build and then published the dist and loader folders with npm publish. Now, I want to add the component to a regular HTML page. The readme instructs to add this to the page head to import the component from unpkg:
I'm also confused about how to import/require the component in a Node module/script. Here's my try at importing it in a module:
import { WowMumComponent } from 'wow-mum-component';
console.log(WowMumComponent);
The above throws this error:
file:index.mjs:2
import { WowMumComponent } from 'wow-mum-component';
^^^^^^^^^^^^^^^
SyntaxError: Named export 'WowMumComponent' not found. The requested module 'wow-mum-component' is a CommonJS module, which may not support all module.exports as named exports.
I followed the instructions to build my project with
npm run build
and then published the dist and loader folders withnpm publish
. Now, I want to add the component to a regular HTML page. The readme instructs to add this to the page head to import the component from unpkg:That file doesn't exist. Instead, this seems to work:
This also seems to work:
Which of these latter two is "correct"? Or are they the same?
Also, src/index.html has two script tags - one for modern browsers that support ES modules and one for older browsers that don't:
But the readme doesn't say what the second tag should look like for unpkg. I tried a few guesses but none of these appear to do anything:
I'm also confused about how to import/require the component in a Node module/script. Here's my try at importing it in a module:
The above throws this error:
And here's my try at requiring it in a script:
The above doesn't throw an error but just logs
undefined
.To summarize, I have four questions, all related to importing and using a published component:
nomodule
fallback)?The text was updated successfully, but these errors were encountered: