Skip to content

Instantly share code, notes, and snippets.

View SarKurd's full-sized avatar
🤓
Golang

Sarbast SarKurd

🤓
Golang
View GitHub Profile
@SarKurd
SarKurd / esm-package.md
Created August 20, 2022 20:06 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@SarKurd
SarKurd / serverless-deploy.yml
Created July 21, 2020 09:56 — forked from hadynz/serverless-deploy.yml
Serverless deploy with state management in S3
name: Continuous deploy
on:
push:
branches: [master]
jobs:
serverless-deploy:
runs-on: ubuntu-latest
@SarKurd
SarKurd / index.js
Created February 11, 2020 21:32
Mini css extract plugin clean up
//https://github.com/webpack/webpack/issues/7300#issuecomment-413959996
class MiniCssExtractPluginCleanUp {
constructor(deleteWhere = /styles(\.[^.]+)?\.js(\.map)?$/) {
this.shouldDelete = new RegExp(deleteWhere);
}
apply(compiler) {
compiler.hooks.emit.tapAsync('MiniCssExtractPluginCleanup', (compilation, callback) => {
Object.keys(compilation.assets).forEach(asset => {
if (this.shouldDelete.test(asset)) {
delete compilation.assets[asset];