ophidian-lib / core

A Component Framework for Obsidian Plugins
ISC License
21 stars 4 forks source link

Update to 0.0.21 causing compile failure #2

Closed sytone closed 7 months ago

sytone commented 7 months ago

After updating to get the latest changes I hit the following issue.

Looking it seems to be something to do with the type definition. I tried to add the typings manually but it is still failing. I loked through your repo to see if there is a setting I am missing but cannot see anything and could also not see any path changes you made for import using the scss: prefix in the import statement.

Suggestions?

✘ [ERROR] Cannot find module 'scss:./dialog.scss'
Require stack:
- D:\repos\gh\obsidian-queryallthethings\node_modules\.pnpm\esbuild-plugin-sass@1.0.1_esbuild@0.17.6\node_modules\esbuild-plugin-sass\index.js [plugin sass]

    node_modules/.pnpm/@ophidian+core@0.0.21_@codemirror+state@6.4.1_@codemirror+view@6.26.3/node_modules/@ophidian/core/src/ui/dialog.ts:2:24:
      2 │ import dialogStyle from "scss:./dialog.scss";
        ╵                         ~~~~~~~~~~~~~~~~~~~~

  This error came from the "onResolve" callback registered here:

    node_modules/.pnpm/monkey-around@2.3.0/node_modules/monkey-around/index.js:24:23:
      24 │         return current.apply(this, args);
         ╵                        ^

    at Object.<anonymous> (file:///D:/repos/gh/obsidian-queryallthethings/node_modules/.pnpm/github.com+sytone+ophidian-lib-build@a8bd3c03867f1f7541a6f94493fbe0436dc0e179/node_modules/@ophidian/build/index.js:198:20)
    at Object.wrapper (D:\repos\gh\obsidian-queryallthethings\node_modules\.pnpm\monkey-around@2.3.0\node_modules\monkey-around\index.js:24:24)
    at setup (D:\repos\gh\obsidian-queryallthethings\node_modules\.pnpm\esbuild-plugin-sass@1.0.1_esbuild@0.17.6\node_modules\esbuild-plugin-sass\index.js:100:15)
    at file:///D:/repos/gh/obsidian-queryallthethings/node_modules/.pnpm/github.com+sytone+ophidian-lib-build@a8bd3c03867f1f7541a6f94493fbe0436dc0e179/node_modules/@ophidian/build/index.js:180:28
    at wrapper (D:\repos\gh\obsidian-queryallthethings\node_modules\.pnpm\monkey-around@2.3.0\node_modules\monkey-around\index.js:24:24)
    at handlePlugins (D:\repos\gh\obsidian-queryallthethings\node_modules\.pnpm\esbuild@0.17.6\node_modules\esbuild\lib\main.js:1279:21)
    at buildOrContextImpl (D:\repos\gh\obsidian-queryallthethings\node_modules\.pnpm\esbuild@0.17.6\node_modules\esbuild\lib\main.js:968:5)
    at Object.buildOrContext (D:\repos\gh\obsidian-queryallthethings\node_modules\.pnpm\esbuild@0.17.6\node_modules\esbuild\lib\main.js:776:5)
    at D:\repos\gh\obsidian-queryallthethings\node_modules\.pnpm\esbuild@0.17.6\node_modules\esbuild\lib\main.js:2172:68
sytone commented 7 months ago

If I manually update the dialog.ts file to use `import "./dialog.scss"; the compile works without error.

pjeby commented 7 months ago

Are you using the latest ophidian/build? It adds support for those import prefixes.

Future versions of ophidian/core should be able to drop this requirement, at least once I figure out how to get pkgroll to do it. The issue is that newer versions of esbuild have a problem with tree-shaking CSS support, such that it includes all the project CSS even if you never use any. I switched to a different way of managing Ophidian's CSS that's compatible with newer esbuild, but the cost is that your build process now has to support those file types.

If you can't use or upgrade ophidian/build, here's the code I'm using that should be adaptable to other esbuild-based build processes.

sytone commented 7 months ago

I am now, I had a forked version as there were path issues, I moved the build script to root and the version you have is working fine. The changes I made were for the copy of the files to the dist directory. I updated the paths to be ./dist/... adding in the prefix of ./

It is all working as expected thanks.

sytone commented 7 months ago

Closing up as the issue is now resolved. Thanks!

pjeby commented 7 months ago

I'm not quite following there -- do you mean that there's a problem in ophidian/build's paths? And if so, in what part exactly? I'm looking at your fork but not seeing any commits in it.