Closed DanielTate closed 3 years ago
I also tested with Yarn yielding the same result. I noticed in your package you are exporting postCSSPlugin
not postCssPlugin
I did try both but didn't seem to get anywhere. Any insight would be great.
If you use ES modules, the default import should work. If not, just use it like this: https://github.com/th8ta/ArConnect/blob/3aa0ee9108ec430dd07303076517fb6df8dc3770/esbuild.js#L36
@martonlederer Thank you for your reply. If I could suggest you add that as a small note for people that don't know about ESM modules that would be helpful. Also in your example you're using require('esbuild') which suggests you're not using esbuild in this case?
After reading a little bit my understanding was adding "type":"module"
to my package would let me use import
statements in node. Would this make my script a "module"? In any case this doesn't change the example code provided. I still get the same errors weather I use this approach or not.
Can you give an example of using ESM and not using ESM?
For any search engine people, this worked for me:
esbuild.build({
...
plugins: [
postCssPlugin.default({
plugins: [ ... ]
})
],
...
})
npm install -D esbuild esbuild-plugin-postcss2
create build.js
run
node build.js
Error: postCssPlugin() is not a function