-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(format): new built-in format for es6 module object (#1380)
* feat(format): new built-in format for es6 module object * feat(format): additional es6 module object test and snapshot * style(format): improve readability with additional indentation Co-authored-by: Joren Broekema <[email protected]> * chore: add changeset and rename to javascript/esm --------- Co-authored-by: Joren Broekema <[email protected]>
- Loading branch information
1 parent
7508c89
commit 0fcf229
Showing
8 changed files
with
289 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'style-dictionary': minor | ||
--- | ||
|
||
Add a new built-in format javascript/esm that outputs an ES module JS default export. |
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,18 @@ | ||
/* @web/test-runner snapshot v1 */ | ||
export const snapshots = {}; | ||
|
||
snapshots["formats javascript/esm should be a valid JS file and match snapshot"] = | ||
`/** | ||
* Do not edit directly, this file was auto-generated. | ||
*/ | ||
export default { | ||
"color": { | ||
"red": { | ||
"value": "#FF0000" | ||
} | ||
} | ||
}; | ||
`; | ||
/* end snapshot formats javascript/esm should be a valid JS file and match snapshot */ | ||
|
16 changes: 16 additions & 0 deletions
16
__tests__/formats/__snapshots__/es6ModuleMinify.test.snap.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* @web/test-runner snapshot v1 */ | ||
export const snapshots = {}; | ||
|
||
snapshots["formats javascript/esm should be a valid JS file and match snapshot"] = | ||
`/** | ||
* Do not edit directly, this file was auto-generated. | ||
*/ | ||
export default { | ||
"color": { | ||
"red": "#FF0000" | ||
} | ||
}; | ||
`; | ||
/* end snapshot formats javascript/esm should be a valid JS file and match snapshot */ | ||
|
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,50 @@ | ||
/* | ||
* Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with | ||
* the License. A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
import { expect } from 'chai'; | ||
import formats from '../../lib/common/formats.js'; | ||
import createFormatArgs from '../../lib/utils/createFormatArgs.js'; | ||
import flattenTokens from '../../lib/utils/flattenTokens.js'; | ||
|
||
const file = { | ||
destination: '__output/', | ||
format: 'javascript/esm', | ||
filter: { | ||
type: 'color', | ||
}, | ||
}; | ||
|
||
const tokens = { | ||
color: { | ||
red: { value: '#FF0000' }, | ||
}, | ||
}; | ||
|
||
const format = formats['javascript/esm']; | ||
|
||
describe('formats', () => { | ||
describe('javascript/esm', () => { | ||
it('should be a valid JS file and match snapshot', async () => { | ||
await expect( | ||
await format( | ||
createFormatArgs({ | ||
dictionary: { tokens, allTokens: flattenTokens(tokens) }, | ||
file, | ||
platform: {}, | ||
}), | ||
{}, | ||
file, | ||
), | ||
).to.matchSnapshot(); | ||
}); | ||
}); | ||
}); |
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,53 @@ | ||
/* | ||
* Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with | ||
* the License. A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
import { expect } from 'chai'; | ||
import formats from '../../lib/common/formats.js'; | ||
import createFormatArgs from '../../lib/utils/createFormatArgs.js'; | ||
import flattenTokens from '../../lib/utils/flattenTokens.js'; | ||
|
||
const file = { | ||
destination: '__output/', | ||
format: 'javascript/esm', | ||
options: { | ||
minify: true, | ||
}, | ||
filter: { | ||
type: 'color', | ||
}, | ||
}; | ||
|
||
const tokens = { | ||
color: { | ||
red: { value: '#FF0000' }, | ||
}, | ||
}; | ||
|
||
const format = formats['javascript/esm']; | ||
|
||
describe('formats', () => { | ||
describe('javascript/esm', () => { | ||
it('should be a valid JS file and match snapshot', async () => { | ||
await expect( | ||
await format( | ||
createFormatArgs({ | ||
dictionary: { tokens, allTokens: flattenTokens(tokens) }, | ||
file, | ||
platform: {}, | ||
}), | ||
{}, | ||
file, | ||
), | ||
).to.matchSnapshot(); | ||
}); | ||
}); | ||
}); |
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