Run test with the source files#9609
Conversation
b8fab1f to
7fdc9cc
Compare
|
@Falke-Design Can you please try with... See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/with - and yes, browsers (except Firefox, it seems) can |
|
I already tried before the same like you suggested Today I found out that named imports are not possible with json:
But this works: And the best part is, that it will be shipped in Firefox with version 138 too: https://www.mozilla.org/en-US/firefox/138.0a1/releasenotes/ (29. April https://whattrainisitnow.com/calendar/) |
|
@jonkoops @IvanSanchez any ideas how we can fix this test?
Leaflet/spec/suites/core/GeneralSpec.js Lines 6 to 12 in 0549bf2 |
|
I don't think we can fix that test, when loading from source the modules are not bundled up into a single file, so that means they are actual standalone modules, which are read-only. I think we need to make a decision on if we still want to allow namespace extension going forwards. If we want to keep some sort of backwards compatibility, we perhaps still need to bundle up the source. |
|
I think we should always provide a bundled file because it can be minified, used in older projects and plugins which will not be maintained can be still working (same namespace). |
|
Perhaps there is some way we could include the bundler as part of the tests so it is automatically rebuilt? |
…e-Design/Leaflet into feat/test_from_source_files
|
For the namespace extension I'm now using the bundled leaflet-src.js. |
|
@jonkoops please review again |
|
Nice work @Falke-Design! |
|
Changing the import to Please consider my #9657 for an alternative and simpler approach. Thank you! /* @preserve
* Leaflet 1.9.2+main.c2946c42, a JS library for interactive maps. https://leafletjs.com
* (c) 2010-2025 Volodymyr Agafonkin, (c) 2010-2011 CloudMade
*/
var name = "leaflet";
var version$1 = "1.9.2+main.e76f97cb";
var homepage = "https://leafletjs.com/";
var description = "JavaScript library for mobile-friendly interactive maps";
var devDependencies = {
"@mapbox/eslint-plugin-script-tags": "^1.0.0",
"@rollup/plugin-json": "^6.1.0",
bundlemon: "^3.0.3",
chai: "^5.1.1",
eslint: "^9.23.0",
"eslint-config-mourner": "^4.0.2",
"eslint-plugin-import-x": "^4.9.1",
"http-server": "^14.1.1",
husky: "^9.1.4",
karma: "^6.4.3",
"karma-chrome-launcher": "^3.2.0",
"karma-coverage": "^2.2.1",
"karma-firefox-launcher": "^2.1.3",
"karma-mocha": "^2.0.1",
"karma-safarinative-launcher": "^1.1.0",
"karma-time-stats-reporter": "^0.1.0",
leafdoc: "^2.3.0",
"lint-staged": "^15.2.7",
mocha: "^10.7.0",
"prosthetic-hand": "^2.0.0",
rollup: "^4.19.1",
"rollup-plugin-git-version": "^0.3.1",
"simple-git": "^3.25.0",
sinon: "^18.0.0",
ssri: "^10.0.6",
"uglify-js": "^3.19.1",
"ui-event-simulator": "^2.0.0"
};
var type = "module";
var exports = {
".": "./dist/leaflet-src.js"
};
var style = "dist/leaflet.css";
var files = [
"dist",
"src",
"!dist/leaflet.zip",
"!*.leafdoc",
"CHANGELOG.md"
];
var scripts = {
debug: "http-server -c-1",
docs: "node ./build/docs.js && node ./build/integrity.js",
test: "karma start ./spec/karma.conf.cjs",
coverage: "karma start ./spec/karma.conf.cjs --coverage --single-run",
build: "npm run rollup && npm run uglify",
lint: "eslint .",
lintfix: "npm run lint -- --fix",
rollup: "rollup -c build/rollup-config.js",
watch: "rollup -w -c build/rollup-config.js",
uglify: "uglifyjs dist/leaflet-src.js -c -m -o dist/leaflet.js --source-map filename=dist/leaflet.js.map --source-map content=dist/leaflet-src.js.map --source-map url=leaflet.js.map --comments",
bundlemon: "bundlemon --subProject js --defaultCompression none && bundlemon --subProject js-gzip --defaultCompression gzip",
serve: "cd docs && bundle exec jekyll serve",
prepare: "husky"
};
var repository = {
type: "git",
url: "git://github.com/Leaflet/Leaflet.git"
};
var keywords = [
"gis",
"map"
];
var license = "BSD-2-Clause";
var pkg = {
name: name,
version: version$1,
homepage: homepage,
description: description,
devDependencies: devDependencies,
type: type,
exports: exports,
style: style,
files: files,
scripts: scripts,
repository: repository,
keywords: keywords,
license: license,
"lint-staged": {
"*.(js|mjs|md)": "eslint --cache --fix"
}
};/* @preserve
* Leaflet 1.9.2+main.c2946c42, a JS library for interactive maps. https://leafletjs.com
* (c) 2010-2025 Volodymyr Agafonkin, (c) 2010-2011 CloudMade
*/
var name="leaflet",version$1="1.9.2+main.e76f97cb",homepage="https://leafletjs.com/",description="JavaScript library for mobile-friendly interactive maps",devDependencies={"@mapbox/eslint-plugin-script-tags":"^1.0.0","@rollup/plugin-json":"^6.1.0",bundlemon:"^3.0.3",chai:"^5.1.1",eslint:"^9.23.0","eslint-config-mourner":"^4.0.2","eslint-plugin-import-x":"^4.9.1","http-server":"^14.1.1",husky:"^9.1.4",karma:"^6.4.3","karma-chrome-launcher":"^3.2.0","karma-coverage":"^2.2.1","karma-firefox-launcher":"^2.1.3","karma-mocha":"^2.0.1","karma-safarinative-launcher":"^1.1.0","karma-time-stats-reporter":"^0.1.0",leafdoc:"^2.3.0","lint-staged":"^15.2.7",mocha:"^10.7.0","prosthetic-hand":"^2.0.0",rollup:"^4.19.1","rollup-plugin-git-version":"^0.3.1","simple-git":"^3.25.0",sinon:"^18.0.0",ssri:"^10.0.6","uglify-js":"^3.19.1","ui-event-simulator":"^2.0.0"},type="module",exports={".":"./dist/leaflet-src.js"},style="dist/leaflet.css",files=["dist","src","!dist/leaflet.zip","!*.leafdoc","CHANGELOG.md"],scripts={debug:"http-server -c-1",docs:"node ./build/docs.js && node ./build/integrity.js",test:"karma start ./spec/karma.conf.cjs",coverage:"karma start ./spec/karma.conf.cjs --coverage --single-run",build:"npm run rollup && npm run uglify",lint:"eslint .",lintfix:"npm run lint -- --fix",rollup:"rollup -c build/rollup-config.js",watch:"rollup -w -c build/rollup-config.js",uglify:"uglifyjs dist/leaflet-src.js -c -m -o dist/leaflet.js --source-map filename=dist/leaflet.js.map --source-map content=dist/leaflet-src.js.map --source-map url=leaflet.js.map --comments",bundlemon:"bundlemon --subProject js --defaultCompression none && bundlemon --subProject js-gzip --defaultCompression gzip",serve:"cd docs && bundle exec jekyll serve",prepare:"husky"},repository={type:"git",url:"git://github.com/Leaflet/Leaflet.git"},keywords=["gis","map"],license="BSD-2-Clause",pkg={name:name,version:version$1,homepage:homepage,description:description,devDependencies:devDependencies,type:type,exports:exports,style:style,files:files,scripts:scripts,repository:repository,keywords:keywords,license:license,"lint-staged":{"*.(js|mjs|md)":"eslint --cache --fix"}}; |
With changing the source files to be completley runnable without any bundler, we can include them directly in the tests.
Loading the
versionfrom thepackage.jsoncaused the problem.Solution: In the source files we have now the version
0.0.0and with running rollup, we replace the version with the version from package.json.Fixes: #8937