forked from mapbox/mapbox-gl-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch dev environment to native ESM to support Node 12+ (mapbox#10367)
* use native ES modules for unit tests * update CircleCI Node image to v14.15 * bump yarn cache key on Circle CI * expose bundles as CommonJS in Node * upgrade postcss and use CJS for config * convert harness and some scripts to esm * fix lint and flow * make sure testem runs with native esm * testem fixups * use custom json loader to support named exports * use a valid access token in unit tests * work around testem refusing to load cjs configs * fix lint * fix testem runs on CI hopefully * fix webpack build
- Loading branch information
Showing
52 changed files
with
966 additions
and
425 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
/rollup/build/ | ||
/dist/ | ||
/dist/mapbox-gl* | ||
/dist/versions* | ||
/dist/style-spec | ||
*.es.js | ||
*.js.map | ||
node_modules | ||
|
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
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 |
---|---|---|
@@ -1,11 +1,9 @@ | ||
/* eslint-disable */ | ||
'use strict'; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const script = fs.readFileSync(path.join(__dirname, '../debug/access_token.js'), 'utf-8') | ||
import fs from 'fs'; | ||
|
||
const script = fs.readFileSync(new URL('../debug/access_token.js', import.meta.url), 'utf-8') | ||
.replace('process.env.MapboxAccessToken', | ||
JSON.stringify(process.env.MapboxAccessToken)) | ||
.replace('process.env.MAPBOX_ACCESS_TOKEN', | ||
JSON.stringify(process.env.MAPBOX_ACCESS_TOKEN)); | ||
|
||
fs.writeFileSync(path.join(__dirname, '../debug/access_token_generated.js'), script); | ||
fs.writeFileSync(new URL('../debug/access_token_generated.js', import.meta.url), script); |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import flowRemoveTypes from '@mapbox/flow-remove-types'; | ||
import {dataToEsm} from '@rollup/pluginutils'; | ||
|
||
const glslRe = /\.glsl$/; | ||
const jsonRe = /\.json$/; | ||
|
||
export function resolve(specifier, context, defaultResolve) { | ||
if (glslRe.test(specifier)) { | ||
const url = new URL(specifier, context.parentURL).href; | ||
return {url}; | ||
} | ||
return defaultResolve(specifier, context, defaultResolve); | ||
} | ||
|
||
export function getFormat(url, context, defaultGetFormat) { | ||
if (glslRe.test(url) || jsonRe.test(url)) { | ||
return {format: 'module'}; | ||
} | ||
return defaultGetFormat(url, context, defaultGetFormat); | ||
} | ||
|
||
export function transformSource(source, context, defaultTransformSource) { | ||
if (source.indexOf('@flow') >= 0) { | ||
source = flowRemoveTypes(source.toString()).toString(); | ||
return {source}; | ||
} | ||
if (glslRe.test(context.url)) { | ||
return {source: `export default \`${source}\``}; | ||
} | ||
if (jsonRe.test(context.url)) { | ||
source = dataToEsm(JSON.parse(source), { | ||
preferConst: true, | ||
namedExports: true, | ||
indent: ' ' | ||
}); | ||
return {source}; | ||
} | ||
return defaultTransformSource(source, context, defaultTransformSource); | ||
} |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
node -r @mapbox/flow-remove-types/register -r esm ${@} | ||
node --no-warnings --experimental-loader ./build/node-loader.js ${@} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
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
File renamed without changes.
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.