-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: This ensures that Pieces will properly load the files from the appropiate folder and we properly bundle CJS and ESM. To use this version of @sapphire/pieces you have to use @sapphire/framework v5.x or higher, or update your own usage of @sapphire/pieces to also properly split ESM and CJS.
- Loading branch information
Showing
10 changed files
with
758 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
onlyBundle: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,19 @@ | ||
import { writeFile } from 'fs/promises'; | ||
|
||
const path = new URL('../dist/lib/internal/internal.js', import.meta.url); | ||
await writeFile(path, ['"use strict";', 'exports.mjsImport = (path) => import(path);', ''].join('\n'), 'utf-8'); | ||
const pathCJS = new URL('../dist/cjs/lib/internal/internal.cjs', import.meta.url); | ||
const pathESM = new URL('../dist/esm/lib/internal/internal.mjs', import.meta.url); | ||
|
||
const baseInternalImport = [ | ||
'const __defProp = Object.defineProperty;', | ||
'const __name = (target, value) => __defProp(target, "name", { value, configurable: true });', | ||
'', | ||
'function mjsImport(path) {', | ||
' return import(path);', | ||
'}', | ||
'', | ||
'__name(mjsImport, "mjsImport");', | ||
'' | ||
]; | ||
|
||
await writeFile(pathCJS, ['"use strict";', '', ...baseInternalImport, 'exports.mjsImport = mjsImport;', ''].join('\n'), 'utf-8'); | ||
await writeFile(pathESM, [...baseInternalImport, 'export { mjsImport };', ''].join('\n'), { encoding: 'utf-8' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
{ | ||
"extends": ["@sapphire/ts-config", "@sapphire/ts-config/extra-strict"] | ||
"extends": ["@sapphire/ts-config", "@sapphire/ts-config/extra-strict", "@sapphire/ts-config/bundler", "@sapphire/ts-config/verbatim"], | ||
"compilerOptions": { | ||
"incremental": false, | ||
"noEmit": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"extends": "./tsconfig.base.json", | ||
"include": ["src", "scripts"] | ||
"include": ["src", "scripts", "tsup.config.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { esbuildPluginFilePathExtensions } from 'esbuild-plugin-file-path-extensions'; | ||
import { defineConfig, type Options } from 'tsup'; | ||
|
||
const baseOptions: Options = { | ||
clean: true, | ||
entry: ['src/**/*.ts', '!src/**/*.d.ts'], | ||
dts: true, | ||
minify: false, | ||
skipNodeModulesBundle: true, | ||
sourcemap: true, | ||
target: 'es2021', | ||
tsconfig: 'src/tsconfig.json', | ||
keepNames: true, | ||
esbuildPlugins: [esbuildPluginFilePathExtensions()], | ||
treeshake: true | ||
}; | ||
|
||
export default [ | ||
defineConfig({ | ||
...baseOptions, | ||
outDir: 'dist/cjs', | ||
format: 'cjs', | ||
outExtension: () => ({ js: '.cjs' }) | ||
}), | ||
defineConfig({ | ||
...baseOptions, | ||
outDir: 'dist/esm', | ||
format: 'esm' | ||
}) | ||
]; |
Oops, something went wrong.