@@ -132,7 +132,8 @@ module.exports = function( grunt ) {
132132 paths : {
133133 cldr : "../external/cldrjs/dist/cldr" ,
134134 "make-plural" : "../external/make-plural/make-plural" ,
135- messageformat : "../external/messageformat/messageformat" ,
135+ "messageformat-parser" : "../node_modules/messageformat-parser/parser" ,
136+ "reserved-words" : "../node_modules/reserved-words/lib/reserved-words" ,
136137 "zoned-date-time" : "../node_modules/zoned-date-time/src/zoned-date-time"
137138 } ,
138139 shim : {
@@ -151,8 +152,7 @@ module.exports = function( grunt ) {
151152 // Only for root id's (the ones in src, not in src's subpaths). Note there's no
152153 // conditional code checking for this type.
153154 onBuildWrite : function ( id , path , contents ) {
154- var messageformat ,
155- name = camelCase ( id . replace ( / u t i l \/ | c o m m o n \/ / , "" ) ) ;
155+ var name = camelCase ( id . replace ( / u t i l \/ | c o m m o n \/ / , "" ) ) ;
156156
157157 // MakePlural
158158 if ( ( / m a k e - p l u r a l / ) . test ( id ) ) {
@@ -200,68 +200,39 @@ module.exports = function( grunt ) {
200200 "/* jshint ignore:end */"
201201 ] . join ( "\n" ) ) ;
202202
203- // messageformat
204- } else if ( ( / m e s s a g e f o r m a t / ) . test ( id ) ) {
205- return contents
203+ // messageformat-parser
204+ } else if ( ( / m e s s a g e f o r m a t - p a r s e r / . test ( id ) ) ) {
206205
207- // Remove browserify wrappers.
208- . replace ( / ^ \( f u n c t i o n \( f \) \{ i f \( t y p e o f e x p o r t s = = = " o b j e c t " & & t y p e .* / , "" )
209- . replace ( "},{}],2:[function(require,module,exports){" , "" )
210- . replace ( / \} , \{ " \. \/ m e s s a g e f o r m a t - p a r s e r " : 1 , " m a k e - p l u r a l \/ p l u r a l .* / , "" )
211- . replace ( / \} , \{ \} \] \} , \{ \} , \[ 2 \] \) \( 2 \) [ \s \S ] * ?$ / , "" )
212-
213- // Set `MessageFormat.plurals` and remove `make-plural/plurals`
214- // completely. This is populated by Globalize on demand.
215- . replace ( / v a r _ c p = \[ [ \s \S ] * ?$ / , "" )
216- . replace (
217- "MessageFormat.plurals = require('make-plural/plurals')" ,
218- "MessageFormat.plurals = {}"
219- )
220-
221- // Set `MessageFormat._parse`
222- . replace (
223- "MessageFormat._parse = require('./messageformat-parser').parse;" ,
224- ""
225- )
226- . replace ( / m o d u l e \. e x p o r t s = \( f u n c t i o n \( \) \{ ( [ \s \S ] * ?) \n \} \) \( \) ; / , [
227- "MessageFormat._parse = (function() {" ,
228- "$1" ,
229- "}()).parse;"
206+ return contents
207+ . replace ( / ^ / , [
208+ "var Parser;" ,
209+ "/* jshint ignore:start */\n" ,
210+ "Parser = (function() {"
230211 ] . join ( "\n" ) )
212+ . replace ( "module.exports = " , "return " )
213+ . replace ( / $ / , [
214+ "}());" ,
215+ "/* jshint ignore:end */"
216+ ] . join ( "\n" ) ) ;
231217
232- // Remove unused code.
233- . replace ( / i f \( ! p l u r a l F u n c \) \{ \n [ \s \S ] * ?\n \} / , "" )
234- . replace ( / i f \( ! l o c a l e \) \{ \n [ \s \S ] * ? \} \n / , "this.lc = [locale];" )
235- . replace ( / ( M e s s a g e F o r m a t \. f o r m a t t e r s ) = \{ [ \s \S ] * ?\n \} ; / , "$1 = {};" )
236- . replace ( / M e s s a g e F o r m a t \. p r o t o t y p e \. s e t I n t l S u p p o r t [ \s \S ] * ?\n \} ; / , "" )
218+ // reserved-words
219+ } else if ( ( / r e s e r v e d - w o r d s / . test ( id ) ) ) {
237220
238- // Wrap everything into a var assignment.
239- . replace ( "module.exports = MessageFormat;" , "" )
221+ return contents
240222 . replace ( / ^ / , [
241- "var MessageFormat;" ,
242- "/* jshint ignore:start */" ,
243- "MessageFormat = (function() {"
223+ "var reserved;" ,
224+ "/* jshint ignore:start */\n" ,
225+ "reserved = (function() {" ,
226+ "var exports = {};"
244227 ] . join ( "\n" ) )
228+ . replace ( "var assert = require\('assert'\);" , "" )
229+ . replace ( / ^ \s * a s s e r t \( .* ; \s * $ / gm, "" )
245230 . replace ( / $ / , [
246- "return MessageFormat ;" ,
231+ "return exports ;" ,
247232 "}());" ,
248233 "/* jshint ignore:end */"
249234 ] . join ( "\n" ) ) ;
250235
251- // message-runtime
252- } else if ( ( / m e s s a g e - r u n t i m e / ) . test ( id ) ) {
253- messageformat = require ( "./external/messageformat/messageformat" ) ;
254- delete messageformat . prototype . runtime . fmt ;
255- delete messageformat . prototype . runtime . pluralFuncs ;
256- contents = contents . replace ( "Globalize._messageFormat = {};" , [
257- "/* jshint ignore:start */" ,
258- "Globalize._messageFormat = (function() {" ,
259- messageformat . prototype . runtime . toString ( ) ,
260- "return {number: number, plural: plural, select: select};" ,
261- "}());" ,
262- "/* jshint ignore:end */"
263- ] . join ( "\n" ) ) ;
264-
265236 // ZonedDateTime
266237 } else if ( ( / z o n e d - d a t e - t i m e / ) . test ( id ) ) {
267238 contents = contents . replace (
0 commit comments