Just giving a chance through a PR for the review of some significant build changes that will affect how JSONPath-Plus is imported. The immediate need is to try to fix #129 , but it is also for the sake of allowing direct import usage in Node ESM modules.
Note that the current use of exports in package.json will prevent Node users (on ESM-supporting versions--version 10 starts such usage, and I believe 14 ships it by default) from importing any other files in the repo (besides the main CJS and ESM builds). If anyone wishes any other files to be exported for some reason, let me know (though I don't see any particular need). It won't remove it from the npm package (so custom bundlers can still grab any file), but it will prevent a Node script directly importing specific paths within the package.
PR description
Overview of breaking changes
Adds support for genuine ESM in Node (type and exports in package.json and
changed main path).
Changes browser paths to include "-browser" in the file name
Adds browser to package.json to point to browser build for browser-specific bundling.
Rollup users wishing the browser bundle must ensure @rollup/plugin-node-resolve
has mainFields to include browser as the first item in the array; Webpack users may
need to set resolve with aliasFields: ['browser'] and/or
mainFields: ['browser', 'module', 'main'], ensuring that browser is in the front of the list
Has module point to the Node-specific build (with a new path)
Summary of all changes
Breaking change: Add type: 'commonjs' and exports: {import, require}
(with node-import-test npm script to demo)
Breaking change: Change paths for browser (now is
dist/index-browser-umd.js or dist/index-browser-es.js)
(for Node, main and module point to new Node-specific dist)
Breaking enhancement: Add browser for browser bundling;
allowing static analysis environments, doesn't have however
conditional code to require vm); for ESM browser bundling,
now must check browser in Rollup Node resolver plugin;
see README
Linting: quote props
Testing: Fix browser tests
Travis: add default dist field to avoid extra config reporting
Just giving a chance through a PR for the review of some significant build changes that will affect how JSONPath-Plus is imported. The immediate need is to try to fix #129 , but it is also for the sake of allowing direct
import
usage in Node ESM modules.Note that the current use of
exports
inpackage.json
will prevent Node users (on ESM-supporting versions--version 10 starts such usage, and I believe 14 ships it by default) from importing any other files in the repo (besides the main CJS and ESM builds). If anyone wishes any other files to be exported for some reason, let me know (though I don't see any particular need). It won't remove it from the npm package (so custom bundlers can still grab any file), but it will prevent a Node script directly importing specific paths within the package.PR description
Overview of breaking changes
type
andexports
inpackage.json
and changedmain
path).browser
topackage.json
to point to browser build for browser-specific bundling. Rollup users wishing the browser bundle must ensure@rollup/plugin-node-resolve
hasmainFields
to includebrowser
as the first item in the array; Webpack users may need to setresolve
withaliasFields: ['browser']
and/ormainFields: ['browser', 'module', 'main']
, ensuring thatbrowser
is in the front of the listmodule
point to the Node-specific build (with a new path)Summary of all changes
type: 'commonjs'
andexports: {import, require}
(withnode-import-test
npm script to demo)dist/index-browser-umd.js
ordist/index-browser-es.js
) (for Node,main
andmodule
point to new Node-specific dist)browser
for browser bundling; allowing static analysis environments, doesn't have however conditional code to requirevm
); for ESM browser bundling, now must checkbrowser
in Rollup Node resolver plugin; see READMEdist
field to avoid extra config reportingChecklist
npm test
, ensuring linting passes