Ah I think Gatsby does not work well with UMD library output. I've changed the third party library to use CommonJS and now I don't need any workarounds.
Here is my rollup config:
import resolve from '@rollup/plugin-node-resolve'; import sourcemaps from 'rollup-plugin-sourcemaps'; export default { input: { index: 'dist-transpiled/index', // 'routing/index': 'dist-transpiled/routing/index' }, output: [ { dir: 'dist/', entryFileNames: '[name].esm.js', chunkFileNames: '[name]-[hash].esm.js', format: 'es', sourcemap: true, }, { dir: 'dist/', format: 'commonjs', preferConst: true, sourcemap: true, }, ], external: (id) => !/^(\.|\/)/.test(id), plugins: [ resolve(), sourcemaps(), ], };
The libraries tsconfig.json:
{ "compilerOptions": { "outDir": "dist-transpiled", "module": "es2015", "lib": ["dom", "es2015"], "moduleResolution": "node", "jsx": "react", "sourceMap": true, "declaration": true, "esModuleInterop": true, "noImplicitReturns": true, "noImplicitThis": true, "noImplicitAny": true, "strictNullChecks": true, "suppressImplicitAnyIndexErrors": true, "noUnusedLocals": true, "noUnusedParameters": true, "allowSyntheticDefaultImports": true, "target": "ES2015", "allowJs": true, "skipLibCheck": true, "strict": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, "isolatedModules": true }, "include": ["src"], "exclude": ["node_modules", "dist"] }
and my build command:
tsc -p . && rollup -c
Sorry @brunnerlivio I missed your comment. That's a great find, I wasn't sure of the root cause myself but your insight is really useful. Thank you.
Worte an article shedding a light on this here: dev.to/brunnerlivio/use-stencil-wi...
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ah I think Gatsby does not work well with UMD library output. I've changed the third party library to use CommonJS and now I don't need any workarounds.
Here is my rollup config:
The libraries tsconfig.json:
and my build command:
tsc -p . && rollup -c
Sorry @brunnerlivio I missed your comment. That's a great find, I wasn't sure of the root cause myself but your insight is really useful. Thank you.
Worte an article shedding a light on this here:
dev.to/brunnerlivio/use-stencil-wi...