-
Notifications
You must be signed in to change notification settings - Fork 35
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
Import default export of markedjs #99
Comments
Hi, unfortunately the marked library does not have an es6 default export ( Can you give more information about your build? |
Basically I'm just trying to use the if (window.WebComponents === undefined) {
console.error(new Error('WebComponents not defined.'));
} else {
window.WebComponents.waitFor(async () => import('@polymer/iron-component-page'));
} This is then passed to both rollup (to create an esm) and webpack (to create an iife). (I wasn't able to use rollup for both as rollup has issues creating an iife if the source has a dynamic import). My rollup config looks something like this: {
input: joinPaths(config.packageRoot, config.docs.templateFiles.entrypoint),
output: {
dir: config.docs.path,
entryFileNames: '[name].min.mjs',
chunkFileNames: 'common/[hash].min.mjs',
format: 'esm',
sourcemap: false
},
treeshake: {
pureExternalModules: true,
propertyReadSideEffects: false,
annotations: true
},
plugins: [
rollupPluginNodeResolve(),
rollupPluginCommonjs(),
rollupPluginTypescript({
tsconfig: joinPaths(config.packageRoot, config.docs.templateFiles.tsconfig)
}),
rollupPluginBabel({
babelrc: false,
extensions: ['.js', '.mjs', '.ts'],
...getBabelConfigModule()
}),
rollupPluginTerser(minModule)
]
} Not sure if it's relevant or not but my source code is written in TypeScript. |
hmm is it possible to exclude the marked js library as a commonjs module? My guess is that your build is treating it as such when we are using it as an es module as marked was written to support all cases. |
That was it. Adding this fixed my issue: rollupPluginCommonjs({
exclude: ['node_modules/marked/**']
}) Thanks for your help. |
Really good to hear, cheers! |
Description
My build breaks when I try to build my app as the markedjs library isn't being imported correctly.
If I change this line:
marked-element/marked-import.js
Line 11 in 0391902
to this:
my build works successfully.
Expected outcome
Actual outcome
Browsers Affected
I assume all but I've only tested on Chromium.
The text was updated successfully, but these errors were encountered: