-
Notifications
You must be signed in to change notification settings - Fork 89
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
Switch from rollup to vite, from commonjs to ecmascript modules #1740
Open
flevi29
wants to merge
11
commits into
meilisearch:main
Choose a base branch
from
flevi29:rollup-to-esm-vite
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a07e07d
Switch from rollup to vite, from cjs to esm
flevi29 8f58b74
Fix env test
flevi29 a95882d
Fix format issues
flevi29 d46f4c2
Fix 'types' script
flevi29 ea6d12d
Fix token test
flevi29 0f88439
Fix env esm test
flevi29 a41e450
Fix env nodejs test
flevi29 4c31f93
Fix env browser test
flevi29 a116354
Remove unnecessary index file, misc
flevi29 5dab3a1
Remove outdated entries from package.json, misc
flevi29 bb95a1c
Fix env test
flevi29 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -16,25 +16,20 @@ | |
"qdequele <[email protected]>" | ||
], | ||
"license": "MIT", | ||
"main": "./dist/bundles/meilisearch.cjs", | ||
"module": "./dist/bundles/meilisearch.mjs", | ||
"typings": "./dist/types/index.d.ts", | ||
"types": "./dist/types/index.d.ts", | ||
Comment on lines
-21
to
-22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EXPLAINER: These are no longer required, as |
||
"jsdelivr": "./dist/bundles/meilisearch.umd.js", | ||
"unpkg": "./dist/bundles/meilisearch.umd.js", | ||
"type": "module", | ||
"jsdelivr": "./dist/umd/index.min.js", | ||
"exports": { | ||
".": { | ||
"types": "./dist/types/index.d.ts", | ||
"browser": "./dist/bundles/meilisearch.umd.js", | ||
"import": "./dist/bundles/meilisearch.mjs", | ||
"require": "./dist/bundles/meilisearch.cjs", | ||
"default": "./dist/bundles/meilisearch.umd.js" | ||
"import": "./dist/esm/index.js", | ||
"require": "./dist/cjs/index.cjs", | ||
"default": "./dist/umd/index.min.js" | ||
}, | ||
"./token": { | ||
"types": "./dist/types/token.d.ts", | ||
"import": "./dist/bundles/token.mjs", | ||
"require": "./dist/bundles/token.cjs", | ||
"default": "./dist/bundles/token.cjs" | ||
"import": "./dist/esm/token.js", | ||
"require": "./dist/cjs/token.cjs", | ||
"default": "./dist/cjs/token.cjs" | ||
} | ||
}, | ||
"sideEffects": false, | ||
|
@@ -44,31 +39,27 @@ | |
}, | ||
"scripts": { | ||
"playground:javascript": "yarn --cwd ./playgrounds/javascript && yarn --cwd ./playgrounds/javascript start", | ||
"cleanup": "shx rm -rf dist/", | ||
"build": "yarn cleanup && rollup -c && rollup -c --environment NODE_ENV:production", | ||
"build:docs": "typedoc", | ||
"watch": "yarn cleanup && rollup -c --watch", | ||
"postbuild": "yarn size && yarn typingsheader", | ||
"build": "vite build && tsc -p tsconfig.build.json && vite --mode production-umd build", | ||
"postbuild": "node scripts/build.js", | ||
"test": "vitest run --coverage", | ||
"types:watch": "nodemon --config nodemon.json", | ||
"types": "yarn tsc", | ||
"test:env:browser": "yarn build && yarn --cwd tests/env/express && yarn --cwd tests/env/express test", | ||
"types": "tsc -p tsconfig.build.json --noEmit", | ||
"types:watch": "yarn types --watch", | ||
"test:env:browser": "yarn build && node scripts/copy-umd-file.js --to ./tests/env/express/public && yarn --cwd tests/env/express && yarn --cwd tests/env/express test", | ||
"test:watch": "vitest watch", | ||
"test:coverage": "yarn test", | ||
"test:ci": "yarn test", | ||
"test:env": "yarn build && yarn test:env:nodejs && yarn test:env:esm && yarn test:env:node-ts", | ||
"test:env:node-ts": "yarn --cwd tests/env/typescript-node start", | ||
"test:env:nodejs": "yarn build && node tests/env/node/index.js && node tests/env/node/getting_started.js", | ||
"test:env:nodejs": "yarn build && node tests/env/node/index.cjs && node tests/env/node/getting_started.cjs", | ||
"test:env:esm": "yarn --cwd tests/env/esm && yarn --cwd tests/env/esm start", | ||
"test:env:nitro-app": "yarn build && yarn --cwd tests/env/nitro-app test", | ||
"size": "node scripts/file-size ./dist/bundles/meilisearch.mjs ./dist/bundles/meilisearch.umd.min.js", | ||
"style": "yarn fmt && yarn lint", | ||
"style:fix": "yarn fmt:fix && yarn lint:fix", | ||
"fmt": "prettier -c ./**/*.{js,ts}", | ||
"fmt:fix": "prettier -w ./**/*.{js,ts}", | ||
"lint": "eslint .", | ||
"lint:fix": "eslint --fix .", | ||
"typingsheader": "node scripts/build.js" | ||
"style": "yarn fmt && yarn lint", | ||
"style:fix": "yarn fmt:fix && yarn lint:fix" | ||
}, | ||
"files": [ | ||
"src", | ||
|
@@ -86,37 +77,25 @@ | |
] | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"@babel/core": "^7.25.2", | ||
"@babel/preset-env": "^7.25.4", | ||
"@eslint/js": "^9.11.1", | ||
"@rollup/plugin-babel": "^6.0.4", | ||
"@rollup/plugin-commonjs": "28.0.0", | ||
"@rollup/plugin-json": "^6.1.0", | ||
"@rollup/plugin-node-resolve": "15.3.0", | ||
"@eslint/js": "^9.13.0", | ||
"@types/eslint__js": "^8.42.3", | ||
"@vitest/coverage-v8": "2.0.5", | ||
"@vitest/eslint-plugin": "^1.1.4", | ||
"@vitest/eslint-plugin": "^1.1.7", | ||
"@types/node": "^22.8.6", | ||
"brotli-size": "^4.0.0", | ||
"eslint": "^9.13.0", | ||
"globals": "^15.11.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-tsdoc": "^0.3.0", | ||
"globals": "^15.11.0", | ||
"gzip-size": "^6.0.0", | ||
"kleur": "^4.1.5", | ||
"lint-staged": "15.2.10", | ||
"nodemon": "^3.1.7", | ||
"prettier": "^3.3.3", | ||
"prettier-plugin-jsdoc": "^1.3.0", | ||
"pretty-bytes": "^5.6.0", | ||
"rollup": "^4.22.5", | ||
"rollup-plugin-typescript2": "^0.36.0", | ||
"shx": "^0.3.2", | ||
"typedoc": "^0.26.10", | ||
"typescript": "^5.4.5", | ||
"typescript-eslint": "^8.12.2", | ||
"vitest": "2.0.5" | ||
"typescript": "^5.6.3", | ||
"vitest": "2.0.5", | ||
"vite": "^5.4.10", | ||
"@typescript-eslint/utils": "^8.12.2" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
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
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,21 @@ | ||
import { parseArgs } from "node:util"; | ||
import { createRequire } from "node:module"; | ||
import { fileURLToPath } from "node:url"; | ||
import { resolve, dirname, join, basename } from "node:path"; | ||
import { copyFile } from "node:fs/promises"; | ||
|
||
const { | ||
values: { to }, | ||
} = parseArgs({ options: { to: { type: "string" } } }); | ||
|
||
if (to === undefined) { | ||
throw new Error("required argument `to` missing"); | ||
} | ||
|
||
const pkg = createRequire(import.meta.url)("../package.json"); | ||
const umdAbsolutePath = resolve( | ||
dirname(fileURLToPath(import.meta.url)), | ||
join("..", pkg.jsdelivr), | ||
); | ||
|
||
await copyFile(umdAbsolutePath, join(to, basename(pkg.jsdelivr))); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
EXPLAINER:
"exports"
is the replacement for these and we no longer officially support Node.js versions prior to 18, so we do not need the backwards compatibility.