Skip to content

Commit

Permalink
fix: Add missing extensions to ESM imports
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlancollins committed Jul 20, 2023
1 parent 4440344 commit 3647bba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"cpy-cli": "^4.2.0",
"current-git-branch": "^1.1.0",
"esbuild": "^0.18.13",
"esbuild-plugin-file-path-extensions": "^1.0.0",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-query/tsup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { defineConfig } from 'tsup'
import { legacyConfig } from '../../scripts/getTsupConfig.js'

export default defineConfig([
legacyConfig({ entry: ['src/*.ts', 'src/*.tsx'], bundle: true }),
legacyConfig({ entry: ['src/*.ts', 'src/*.tsx'] }),
])
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions scripts/getTsupConfig.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// @ts-check

import { esbuildPluginFilePathExtensions } from 'esbuild-plugin-file-path-extensions'

/**
* @param {Object} opts - Options for building configurations.
* @param {string[]} opts.entry - The entry array.
* @param {boolean} [opts.bundle] - Whether to bundle the output.
* @returns {import('tsup').Options}
*/
export function modernConfig(opts) {
Expand All @@ -12,18 +13,16 @@ export function modernConfig(opts) {
format: ['cjs', 'esm'],
target: ['chrome91', 'firefox90', 'edge91', 'safari15', 'ios15', 'opera77'],
outDir: 'build/modern',
bundle: opts.bundle || false,
splitting: opts.bundle || false,
dts: true,
sourcemap: true,
clean: true,
esbuildPlugins: [esbuildPluginFilePathExtensions({ esmExtension: 'js' })],
}
}

/**
* @param {Object} opts - Options for building configurations.
* @param {string[]} opts.entry - The entry array.
* @param {boolean} [opts.bundle] - Whether to bundle the output.
* @returns {import('tsup').Options}
*/
export function legacyConfig(opts) {
Expand All @@ -32,10 +31,9 @@ export function legacyConfig(opts) {
format: ['cjs', 'esm'],
target: ['es2020', 'node16'],
outDir: 'build/legacy',
bundle: opts.bundle || false,
splitting: opts.bundle || false,
dts: true,
sourcemap: true,
clean: true,
esbuildPlugins: [esbuildPluginFilePathExtensions({ esmExtension: 'js' })],
}
}

0 comments on commit 3647bba

Please sign in to comment.