Skip to content

Commit

Permalink
Support numeric separator (#3626)
Browse files Browse the repository at this point in the history
* Support numeric separator

Ref rollup/rollup#3605

* Fix test

* Upgrade license

* Add test

Co-authored-by: Lukas Taegert-Atkinson <[email protected]>
  • Loading branch information
TrySound and lukastaegert authored Jun 12, 2020
1 parent 872e9e2 commit bacfcbe
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 5 deletions.
27 changes: 27 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,33 @@ Repository: https://github.com/acornjs/acorn-class-fields
---------------------------------------

## acorn-numeric-separator
License: MIT
By: Adrian Heine
Repository: https://github.com/acornjs/acorn-numeric-separator

> Copyright (C) 2017-2018 by Adrian Heine
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
---------------------------------------

## acorn-private-class-elements
License: MIT
By: Adrian Heine
Expand Down
14 changes: 10 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"acorn": "^7.3.1",
"acorn-class-fields": "^0.3.6",
"acorn-jsx": "^5.2.0",
"acorn-numeric-separator": "^0.3.2",
"acorn-static-class-features": "^0.2.3",
"acorn-walk": "^7.1.1",
"buble": "^0.20.0",
Expand Down
2 changes: 2 additions & 0 deletions src/utils/options/normalizeInputOptions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import injectClassFields from 'acorn-class-fields';
import injectNumericSeparator from 'acorn-numeric-separator';
import injectStaticClassFeatures from 'acorn-static-class-features';
import {
ExternalOption,
Expand Down Expand Up @@ -115,6 +116,7 @@ const getAcorn = (config: GenericConfigObject): acorn.Options => ({
const getAcornInjectPlugins = (config: GenericConfigObject): Function[] => [
injectClassFields,
injectStaticClassFeatures,
injectNumericSeparator,
...(ensureArray(config.acornInjectPlugins) as any)
];

Expand Down
3 changes: 3 additions & 0 deletions test/form/samples/numeric_separators/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
description: 'supports numeric separators'
};
3 changes: 3 additions & 0 deletions test/form/samples/numeric_separators/_expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const x = 123_456;

export { x };
1 change: 1 addition & 0 deletions test/form/samples/numeric_separators/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const x = 123_456;
2 changes: 1 addition & 1 deletion test/function/samples/options-hook/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
preserveParens: false,
sourceType: 'module'
},
acornInjectPlugins: [null, null],
acornInjectPlugins: [null, null, null],
context: 'undefined',
experimentalCacheExpiry: 10,
inlineDynamicImports: false,
Expand Down
5 changes: 5 additions & 0 deletions typings/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ declare module 'acorn-export-ns-from' {
const plugin: (BaseParser: typeof acorn.Parser) => typeof acorn.Parser;
export default plugin;
}

declare module 'acorn-numeric-separator' {
const plugin: (BaseParser: typeof acorn.Parser) => typeof acorn.Parser;
export default plugin;
}

0 comments on commit bacfcbe

Please sign in to comment.