Repository navigation
Step 11: alasql/esm, and the build without keepNames - #2848
Merged
Merged
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Step 11 of the ES6 conversion (
context/roadmap-phase-1.md), the part before the release:alasql/esm. The version bump, the publish to thenextdist-tag and the merge of #1860 are the maintainer's.Two ES module files, one subpath.
package.jsonmaps./esmby condition:nodetodist/alasql.mjs,defaulttodist/alasql.browser.mjs, withtypesfirst. Both are the same bundle in esbuild's esm format, ending inexport default:dist/alasql.mjskeeps the lazyrequire()calls of the externals (fs, path, the optional libraries) and the__dirnamethatfindAlaSQLPathreturns, so it defines both at the top fromimport.meta.url(createRequire,fileURLToPath). That banner is in this file only.dist/alasql.browser.mjsis the browser file's content as a module: the not-for-browser blocks are out,__dirnameis'', and no line importsmodule,fs,pathorurl. The tworequire("fs")andrequire("path")calls left in it are the jison parser's command-line main, inside a function the browser never calls; esbuild turns them into its__requireshim, which a bundler does not try to resolve.No
"use strict"is prepended to the module files (modules are strict), and the CommonJSmodule.exportstail is not applied to them. The other dist files are byte-identical to the step 10 build apart from the build string.Smokes (
test/parity/smoke.js): the Node file imported in-process (SELECT 1+1, andfindAlaSQLPath()returns a string); the browser file in a child node with the import list checked; the browser file bundled by esbuild withplatform: 'browser'; and, under--pack,import alasql from 'alasql/esm'from an installed copy, which takes thenodecondition.Release notes: the draft is at the end of this description.
The SEARCH case, traced. The json-path case "SEARCH through nested arrays" (
SEARCH / orders / items / WHERE(price > 100) price FROM ?over 5,000 nested documents) was +27 percent on Bun and +37 on Node against 4.21.0 at the end of the phase. Across the step builds, 7 runs each on both runtimes, it reads:It came with the bundler in step 1, not with a conversion step, and it is esbuild's
keepNames: its__name()helper runs at every creation of a named function, and SEARCH createsprocessSelectorinside#doSearchand recurses through it. Without keepNames the whole json-path group is -4 on Bun and 0 on Node, and the two.namevalues keepNames still protected (alasql.utils.cloneDeep,alasql.stdfn.EXTEND) are kept by declaring the two functions insrc/utils/helpers.jsas function declarations, which esbuild does not suffix. The API snapshot of the parity check shows 0 changed paths after that. Two commits, "Declare extend and cloneDeep as functions" and "Build without keepNames", separate from the ES module work; the unminified files shrink by about 11 KB.The end-of-phase full benchmark was run again on this build, on a quiet machine: 99 (Bun 100, Node 99) against 4.21.0, from 102 on the step 9 build. Four dimensions were marked (set-ops, coercion and shapes on Bun, mutation on Node) and a focused run of 7 put all four within 4 percent or faster, with the single cases behind them flipping sign; json-path reads -1 and +2, and the JOIN baseline case of the step 9 investigation reads -37 on Bun on this build, the same layout effect the other way. Detail in ledger row 11.
Checks
alasql.min.js524,607 bytes, unchanged by keepNames;alasql.fs.js918,768, 11 KB under step 10; the package grows by the two module files,alasql.mjs918,497 / 140,522 andalasql.browser.mjs913,425 / 139,680 bytes / gzip (the pack is 3,038,249 bytes, from 2,760,848); row 11 intest/parity/ledger.md, whose size table lists .mjs files nowtest/parity/ledger.mdrow 11 carries this pull request's number and the sizes of the two new files.Release notes draft
4.22.0 (pre-release on the
nextdist-tag)The same alasql, built from ES modules. Every numbered source file is a module under
src/now, bundled by esbuild into the same dist files with the same names and the sameexports; the concatenation build is gone. Nothing about the SQL, the API or the behaviour was meant to change, and the checks below say it did not. Please try it from thenexttag before it becomeslatest:What is new
alasql/esm: an ES module entry. Under Node it resolves todist/alasql.mjs; in browsers and bundlers todist/alasql.browser.mjs, which has no Node import in it.import alasql from 'alasql/esm'. It is the same engine as the default entry; the root entry still resolves to the CommonJS files, so a project that mixesrequire('alasql')andimport ... from 'alasql/esm'gets two instances with separate databases.What was checked
test/parity/): the suite and the dialect cases, 77,053 statements in order, recorded on this build and ondevelopat Fix REFERENCES crash with FILESTORAGE to address #1846 #2798 built the old way, compared result by result and compiled function by compiled function: 0 differences. The public API, every property path reachable fromalasql, is identical apart from the.nameof eleven stateless helpers that are exports now.alasql.min.jsunder node, Node 16 and 24,npm packand install withrequire,importand the CLI, and the two ES module files.alasql.min.js524,607 bytes (4.21.0: 520,504), 0.8 percent more;alasql.fs.js918,768 bytes and 140,210 gzipped (4.21.0: 840,681 and 167,149). esbuild reprints the code, so the unminified files are not the old text; they are the same code.What was not checked, and where to look if you use it
IndexedDB and localStorage in a real browser, React Native, sql.js and Meteor are not covered by the suite or the smokes; their code moved unchanged, but nothing ran it. A report from any of these environments is welcome.
Known, found on the way, unchanged in this release
WITH t(a) AS (SELECT ...)throwsReferenceError: renameColumns is not defined(WITH t(a) AS (SELECT ...) throws ReferenceError: renameColumns is not defined #2841, since 4.11.0).ATTACH DATABASEthrowsTypeError: error is not a function(FILESTORAGE: ATTACH DATABASE throws TypeError: error is not a function, and createTable's message reads an undefined fsdbid #2846).For contributors
bun build.jsbuilds;yarn testbuilds and runs the suite. The source issrc/index.jsand the folders beside it;docs/src-map.mdsays where each old numbered file went.fac32eef); it is listed in.git-blame-ignore-revs, so blame still reaches the old files. A clone that wants the same:git config blame.ignoreRevsFile .git-blame-ignore-revs.