-
Notifications
You must be signed in to change notification settings - Fork 68
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
Use Config file instead of Environment Variables #2227
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
2959334
Add cosmiconfig
AlbertoBrusa e1571dd
Allow use esbuild to be configured by a modular configuration file
AlbertoBrusa dac6289
Update comments
AlbertoBrusa 7fb5370
Update config logic
AlbertoBrusa 33742bf
Fix config
AlbertoBrusa cde234d
Change the default CDN to esm.sh
AlbertoBrusa dc77942
Update test snapshots for change to esm.sh
AlbertoBrusa cec53a1
More configurables
AlbertoBrusa f854b5e
https config
AlbertoBrusa 249390f
Let JS files in react-scripts use config.ts using ts-node/register
AlbertoBrusa 7e08f6a
Fix ts-node register
AlbertoBrusa b9b4f5b
More require ts-node register
AlbertoBrusa 675b10f
Remove HOST and HTTPS config
AlbertoBrusa 73fee89
Configurable PUBLIC_URL & GENERATE_SOURCEMAP
AlbertoBrusa b08bd37
Undo changes for PUBLIC_URL & GENERATE_SOURCEMAP config
AlbertoBrusa 5054f28
2nd attempt re-implementing config for generate sourcemap and public url
AlbertoBrusa 755a13f
Add changeset
AlbertoBrusa 1a447a3
Documentation
AlbertoBrusa ee938f7
Update changelog
AlbertoBrusa 7eead44
Update documentation
AlbertoBrusa 5a94077
Update docs/releases/4.0.x.md
AlbertoBrusa 142b7ef
Update documentation
AlbertoBrusa c085182
Merge branch 'config' of https://github.com/AlbertoBrusa/modular into…
AlbertoBrusa c8ef95c
Improved config function
AlbertoBrusa 6175809
Update config function
AlbertoBrusa f73878e
Refactor config function
AlbertoBrusa 7448a3b
Removed unnecessary type annotations
AlbertoBrusa f0e2e93
More cleaning up of Config()
AlbertoBrusa 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'modular-scripts': major | ||
--- | ||
|
||
Changed default CDN from Skypack to esm.sh as skypack is no longer actively | ||
maintained. Add support for configuring modular through a configuration file. |
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,3 @@ | ||
module.exports = { | ||
useModularEsbuild: true, | ||
}; |
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
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 |
---|---|---|
|
@@ -46,7 +46,9 @@ const resolveModular = (relativePath) => | |
const publicUrlOrPath = getPublicUrlOrPath( | ||
process.env.NODE_ENV === 'development', | ||
require(resolveApp('package.json')).homepage, | ||
process.env.PUBLIC_URL, | ||
process.env.INTERNAL_PUBLIC_URL === '' | ||
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. letting getConfig return undefined would have been messy, but treating '' (empty string) as configuration not set might not be ideal either, open to suggestions |
||
? undefined | ||
: process.env.INTERNAL_PUBLIC_URL, | ||
); | ||
|
||
const buildPath = path.join(modularRoot, 'dist', modularPackageName); | ||
|
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
2 changes: 1 addition & 1 deletion
2
packages/modular-scripts/src/__tests__/__snapshots__/esmView.test.ts.snap
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,7 +1,7 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`modular-scripts WHEN building a esm-view THEN matches the entrypoint snapshot 1`] = ` | ||
"import * as t from "https://cdn.skypack.dev/[email protected]"; | ||
"import * as t from "https://esm.sh/[email protected]"; | ||
function e() { | ||
return t.createElement( | ||
"div", | ||
|
51 changes: 51 additions & 0 deletions
51
packages/modular-scripts/src/__tests__/utils/config.test.ts
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,51 @@ | ||
import execa from 'execa'; | ||
import { copyFileSync } from 'fs'; | ||
import path from 'path'; | ||
import { createModularTestContext } from '../../test/utils'; | ||
import getModularRoot from '../../utils/getModularRoot'; | ||
|
||
const modularRoot = getModularRoot(); | ||
const configFixtures = path.join(modularRoot, '__fixtures__', 'test-config'); | ||
|
||
/** | ||
* Run modular with provided arguments in specified directory | ||
*/ | ||
function modular( | ||
args: string, | ||
cwd: string, | ||
opts: Record<string, unknown> = {}, | ||
) { | ||
return execa('yarnpkg', ['modular', ...args.split(' ')], { | ||
cwd, | ||
cleanup: true, | ||
...opts, | ||
}); | ||
} | ||
|
||
// Temporary test context paths set by createTempModularRepoWithTemplate() | ||
let tempModularRepo: string; | ||
|
||
describe('A simple modular repo with a .modular.js config file', () => { | ||
beforeEach(async () => { | ||
tempModularRepo = createModularTestContext(); | ||
await modular('add test-app --unstable-type app', tempModularRepo); | ||
copyFileSync( | ||
path.join(configFixtures, '.modular.js'), | ||
path.join(tempModularRepo, '.modular.js'), | ||
); | ||
}); | ||
it('builds using esbuild as specified in config file', async () => { | ||
const result = await modular(`build test-app --verbose`, tempModularRepo); | ||
expect(result.stdout).toContain('Building with esbuild'); | ||
expect(result.exitCode).toBe(0); | ||
}); | ||
it('builds using webpack if the environment variable is provided as it overrides the config', async () => { | ||
const result = await modular(`build test-app --verbose`, tempModularRepo, { | ||
env: { | ||
USE_MODULAR_ESBUILD: 'false', | ||
}, | ||
}); | ||
expect(result.stdout).toContain('Building with Webpack'); | ||
expect(result.exitCode).toBe(0); | ||
}); | ||
}); |
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
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.
Not sure in the slightest why that popped up now but it was complaining for missing typings for lodash