-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace webpack with esbuild #5086
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import {createRequire} from 'node:module'; | ||
|
||
import esbuild from 'esbuild'; | ||
|
||
import {getFeatures, getFeaturesMeta} from './readme-parser.js'; | ||
|
||
const {resolve: resolvePackage} = createRequire(import.meta.url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space generously gifted by our lint rules 😌
Blocked by 🤷♂️ |
I'll give you 2 plugins to solve
import {readFile} from 'node:fs/promises'
import {pathToFileURL} from 'node:url'
const importMeta: esbuild.Plugin = {
name: 'Import Meta',
setup(build) {
build.onLoad({filter: /source.features.\S+\.tsx$/}, async args => {
let contents = await readFile(args.path, 'utf8');
contents = contents.replace(
/\bimport\.meta\.url\b/g,
JSON.stringify(pathToFileURL(args.path)),
);
return { contents, loader: 'default' }
});
},
};
const TypedQuerySelector: esbuild.Plugin = {
name: 'typed-query-selector',
setup(build) {
build.onResolve({filter: /^typed-query-selector$/}, ({path}) => {
return { path, namespace: 'typed-query-selector' };
});
build.onLoad({filter: /()/, namespace: 'typed-query-selector'}, (a) => {
return { contents: '', loader: 'js' };
});
},
} Note that it may not pass type checking, but you can know what it do. |
Thank you! |
To do:
Notes: