I am having this issue where the output of my RollupJS package is throwing an error when it is run. Here is the Error:
Error: Command failed: node /path/to/test/package/root/index.js
/path/to/main/package/dist/cjs/index.js:33
const _tmpl$$3 = Web.template(`<div><h1>Error: </h1><p></p></div>`, 6);
^
TypeError: Web.template is not a function
at Object.<anonymous> (/Users/patrickluy/Documents/Business/Perivel/tools/solidus.js/packages/solidus/dist/cjs/index.js:33:22)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at Object.<anonymous> (/Users/patrickluy/Documents/Business/Perivel/tools/solidus.js/packages/solidus-example-starter/dist/index.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
Web is implying to the “solid-js/web” package I am depending on. I’m not actually sure why this is occuring. I followed the documentation on Rollup and included all my dependencies on the external
and global
options. Below is my Rollup configuration file:
export default [
// lib
{
input: resolve(__dirname, 'index.ts'),
treeshake: false,
preserveEntrySignatures: false,
external: [
"@swindle/core",
"@swindle/color",
"express", ,
'solid-js',
'solid-js/web'
],
output: [
{
format: "cjs",
dir: resolve("dist/cjs"),
sourcemap: true,
globals: {
'solid-js': 'solidjs',
'solid-js/web': 'web',
'@swindle/color': 'color',
'@swindle/core': 'core',
'express': 'express',
'path': 'path'
}
},
{
format: "esm",
dir: resolve("dist/esm"),
sourcemap: true,
globals: {
'solid-js': 'solidjs',
'solid-js/web': 'web',
'@swindle/color': 'color',
'@swindle/core': 'core',
'express': 'express',
'path': 'path'
}
},
{
name: "solidus",
format: "umd",
dir: resolve("dist/umd"),
sourcemap: true,
plugins: [terser()],
globals: {
'solid-js': 'solidjs',
'solid-js/web': 'web',
'@swindle/color': 'color',
'@swindle/core': 'core',
'express': 'express',
'path': 'path'
}
},
],
plugins: [
nodePolyfillPlugin(),
nodeResolve({
extensions: [".js", ".ts", ".tsx"]
}),
babel({
extensions: [".js", ".ts", ".tsx"],
babelHelpers: "bundled",
presets: ["solid", "@babel/preset-typescript"],
exclude: "node_modules/**"
})
]
},
// CLI
{
input: resolve(__dirname, 'cli.ts'),
external: [
"@swindle/core",
"@swindle/color",
"@swindle/os",
"@swindle/filesystem",
"express",
"serve-static",
"rollup",
"@rollup/plugin-node-resolve",
"@rollup/plugin-babel",
"@rollup/plugin-json",
"@rollup/plugin-typescript",
"rollup-plugin-styles",
"rollup-plugin-copy",
"@web/rollup-plugin-import-meta-assets",
"rollup-plugin-polyfill-node",
"@rollup/plugin-image",
// "solid-js",
// "solid-js/web"
],
output: [
{
file: "./dist/bin/solidus.js",
format: "cjs",
globals: {
// globals
// "@swindle/core": "swindleCore",
// "@swindle/color": "swindleColor",
// "@swindle/os": "swindleOS",
// "@swindle/filesystem": "swindleFS",
// "express": "express",
// "serve-static": "serveStatic",
// "rollup": "rollup",
// "@rollup/plugin-node-resolve": "resolve",
// "@rollup/plugin-babel": "babelPlugin",
// "@rollup/plugin-json": "jsonPlugin",
// "@rollup/plugin-typescript": "typescriptPlugin",
// "rollup-plugin-styles": "stylesPlugin",
// "rollup-plugin-copy": "copyPlugin",
// "@web/rollup-plugin-import-meta-assets": "assetsPlugin",
// "rollup-plugin-polyfill-node": "polyfills",
// "@rollup/plugin-image": "imagePlugin",
// "solid-js": "solid",
// "solid-js/web": "web"
}
},
],
plugins: [
typescriptPlugin(),
nodePolyfillPlugin(),
jsonPlugin(),
hashbangPlugin(),
],
}
];
As you can see here, I have included both solid-js
and solid-js/web
as external dependencies, as per the documentation. However, this is still causing the output to throw the error.
I’m kind of at a loss as to how to resolve this. So, I’d appreciate any help.